Giter VIP home page Giter VIP logo

chill-vm's Introduction

ChillVm, a particularly not useful virtual machine written in Haskell

ChillVm reads chill-bytecode, which is a sequnce of strings of '๐Ÿค™' and '๐Ÿ‘', delimited by '\n'.

Bytecode files contain bytecode instructions, one per line, encoded by 'chilling' and 'nice' emojis

ChillVm has 256 integer (8bit-)registers, can perform math operations on them

ChillVm can also perform ascii string operations (which is a big irony, considering the bytecode is utf), but string size is limited to 256 chars, as well as string storage is same as integer registers

In other words, loading a 256-chars string will erase every register

Checkout a hello world example written in chill-bytecode

Build and run

git clone https://github.com/ghB111/chill-vm.git
cd chill-vm
./install-libs.sh
./build.sh
./build/chill-run ./ex-hello-world.txt

Chill vm has a set of particularly not useful instructions (0=๐Ÿค™, 1=๐Ÿ‘):

00000000: chl (chill~~, basically, nop)
00000001: ldc, 1: register idx, 2: constant to load
00000010: nul, 1: register to set to null
00000011: ld, 1: register idx, 2: register from which to copy
00000100: sgf, produce segfault (debug feature)
00000101: jmp, 1: where to jump
00000110: pls, 1: reg, 2: reg to store result (1+2)
00000111: mns, 1: reg, 2: reg to store result (1-2)
00001000: zbr, 1: where to jump, if last operation returned 0
00001001: bbr, 1: where to jump, if last operation returned >0
00001010: lbr, 1: where to jump, if last operation returned <0
00001011: cmp, same as mns, doesn't store result
00001100: prt, 1: register with pointer to where the string begins, 2: register where string length is stored
00001101: rdc, 1: register with pointer to place where a read char will be stored
11111111: stp, stops execution

Possible todos:

  • Stop using unsafePerformIO
  • Read user input
  • Macroinstructions
  • Assembly dsl?
  • Make it an actual stack project

chill-vm's People

Contributors

ghb111 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.