A simple 8-bit stack VM implementation in SQLite.
All SQL is hand written in emulator.sql
.
Programs are stored as SQLite database files and can be created with assembler.py
.
Samples programs can be found in examples/
.
Assemble a program:
python3 assembler.py examples/sum.asm examples/sum.db
And run it:
./emulator.sh examples/sub.db
- 8-bit
- stack based (no registers)
- unlimited stack
- 256 bytes program memory
- 256 bytes RAM
stack: -> x
stack: _ ->
stack: x -> x x
stack: x0 x1 ... xn -> x1 ... xn x0
stack: x y -> x+y
stack: x y -> x-y
stack: x y -> x&y
stack: x y -> x|y
stack: x -> ~x
pc: x
stack: x ->
pc: x
stack: c ->
pc: if c=0
, x
stack: c x ->
pc: if c=0
, x
stack: -> pc + 2
pc: x
stack: x -> pc + 1
pc: x
stack: i -> memory[i]
stack: x i ->
memory: [i] = x