You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Taylor Bockman
80b801753e
|
8 years ago | |
---|---|---|
include | 8 years ago | |
src | 8 years ago | |
.gitignore | 8 years ago | |
CMakeLists.txt | 8 years ago | |
README.md | 8 years ago |
README.md
uVM - Micro Virtual Machine
uVM is simply an experiment ins developing a working virtual machine with it's own bytecode.
Requirements
- CMake version 3.8 or higher
- Clang and Clang++
Building
git clone
the repositorycmake .
make
Architecture
uVM is a stack machine. That is, it gets all of it's arguments from the stack, and returns the result of the computation back to the stack when it's done.
There are some exceptions to this. In particular the current version of uvm supports a single variable,
called 0
, that can be written to using xpop0
where x is the datatype of the thing getting taken off
the stack.
Additionally 0
can be placed on the top of the stack using xpush0
.
uVM Instruction Set
uVM possesses the standard issue instruction set you might expect in a simple VM:
Instruction | Opcode | Action |
---|---|---|
ipush X | 0 | Pushes integer X onto the stack |
ipush0 | 1 | Pushes the integer in 0 onto the stack |
ipop0 | 2 | Pops the top integer of the stack off and into variable 0 |
icmp | 3 | Compares the top two items on the stack together and returns a boolean result |
iadd | 4 | Adds the top two integer arguments of the stack together |
isub | 5 | Subtracts the top two integer arguments of the stack from each other |
jmp LABEL | 6 | Unconditional jump to label |
jc LABEL | 7 | Jump if the top of the stack is a 1 |
As I learn more about VM development this instruction set will likely become much more robust.