/mac

A simple virtual machine for educational purposes

Primary LanguageC

mac

A simple virtual machine for educational purposes. Made following blog post.

Instruction set

  • PSH ; push to the stack
  • ADD ; pop two values on top of the stack, adds them pushes to stack
  • POP ; pops the value on the stack, will also print it for debugging
  • SET ; set a value into a register
  • HLT ; stop the program

Test program

PSH, 5,

PSH, 6,

ADD,

POP

HLT


The test program will push 5 and 6 to the stack, then add the two values and psuh the result back on the stack. The POP instruction will print the result value for debugging purposes.

Compile and Run

Requirements

  • CMAKE

use 'make' to compile and run with './mac'