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
- Host: GitHub
- URL: https://github.com/tervicke/svm
- Owner: Tervicke
- Created: 2021-06-09T07:57:40.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-09T13:18:02.000Z (about 5 years ago)
- Last Synced: 2025-03-03T06:46:42.345Z (over 1 year ago)
- Topics: c, pops, stack, virtual-machine, vm, vms
- Language: C
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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