# A Minimal Instruction Set
## Execution
First, let $k = 2^n$ where $n \in \N, n > 4$.
The memory is infinite ($2^{k}$) holding $k$-bit unsigned integers in each cell.
The is a program counter is usually increased by one every cycle. Every cycle the program counter is dereferenced and the corresponding instruction is executed.
The inputs will be popped from a stack, the results pushed back. The start of program is at 0, immediatly followed by the stack, growing positively.
2
## Instructions
Instructions start at $2^{k}-1-l$ up to $2^k-1$ with $l$ being the total number of instructions. All other values executed will literally be pushed to the stack.
0. Stop execution: `HALT`
0. Dereference (write): `STORE` (val, ptr) -> ()
0. Dereference (read): `LOAD` (ptr) -> (value)
0. Input: `IN` () -> (x)
0. Output: `OUT` (x) -> ()
0. Duplicate top: `DUP` (x) -> (x, x)
0. Add: `ADD` (x, y) -> (z)
0. Subtract: `SUB` (x, y) -> (z)
0. Multiply: `MUL` (x, y) -> (z)
0. Divide: `DIV` (x, y) -> (z)
0. Modulate: `MOD` (x, y) -> (z)
0. And: `AND` (x, y) -> (z)
0. Or: `OR` (x, y) -> (z)
0. Check equality: `EQ` (x, y) -> (z)
0. Invert: `NOT` (x) -> (z)
0. Load program counter: `PC` () -> (pc)
0. Set program counter: `JUMP` (pc) -> ()
0. Load stack pointer: `SP` () -> (sp)
0. Set stack pointer: `SSP` (sp) -> ()