Tervicke / SVM

Simple stack based virtual machine with its own simple bytecode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple stack based Virtual machine

build

clone the repo and fire the make command

changing the program

to change the program edit the
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

About

Simple stack based virtual machine with its own simple bytecode


Languages

Language:C 94.7%Language:Makefile 5.3%