A simple stack-based virtual machine written in assembly, supporting basic arithmetic operations, stack manipulation, and input handling.
This project implements a stack-based virtual machine that can perform arithmetic and stack operations. It handles input, parses commands, and executes them, while providing error handling for various runtime conditions.
- Arithmetic Operations:
add
,sub
,mul
,div
- Stack Operations:
dup
,pop
- Program Control:
exit
- Stack Size: 512 bytes
- Input Buffer Size: 128 bytes
- Commands: Function pointers, mnemonics, and operand counts.
- Stack: Space for the VM stack.
- Input Buffer: Space for standard input.
- Mnemonics: Literal strings for each command.
- Errors: Various runtime error messages.
- Arithmetic:
add
,sub
,mul
,div
- Stack:
dup
,pop
- Control:
exit
- Peek:
stack_peek
- Pop:
stack_pop
unknown instruction
insufficient stack
stack overflow
stdin is empty
stdin overflow
missing operand
unexpected char
too many operands
- add 5 5:
5+5=10
- sub 2:
2-10=(-8)
- mul 3:
(-8)x3=(-24)
- pop:
-24
- pop:
-8
- exit