An open API service indexing awesome lists of open source software.

https://github.com/tervicke/svm

Simple stack based virtual machine with its own simple bytecode
https://github.com/tervicke/svm

c pops stack virtual-machine vm vms

Last synced: 11 months ago
JSON representation

Simple stack based virtual machine with its own simple bytecode

Awesome Lists containing this project

README

          

simple stack based Virtual machine


build


clone the repo and fire the make command

changing the program


to change the program edit the

```c
int program[] = {
PSH, 15,
PSH, 3,
DIV,
HLT,
//the stack pointer must pointing to value 5
};
```
Note the program is array so dont forget to put , after every instructions

instruction set

Operation | Description
------ | ------
PSH | pushes the value to the top of the stack
POP | pops the value , now the stack pointer points to the previous value
ADD | Adds the the top two values and pushes them
SUB | substracts the the second value from the previous
MUL | multiples top two values on the stack
Div | divides the top value by the first second top value
AND | does the binary AND operation and on the top two value
OR | does the binary OR operation and on the top two value
HLT | Marks the end of the program