2 JNZ [2, A, B]: if register $A isn't equal to zero, jump to the value of B
3 ADD [3, A, B, C]:
if C is 0, add reg $A and mem B, store in A
if C is 1, add reg $A and reg $B, store in A
if C is 2, add mem A and mem B, store in reg A
4 SUB [4, A, B, C]:
if C is 0, subtract mem B from reg $A, store in reg A
if C is 1, subtract reg $B from reg $A, store in reg A
if C is 2, subtract mem B from mem B, store in reg A
5 PSH [5, A]: push the value of register $A to the stack
6 POP [6, A]: pop the top value on the stack, into register $A
7 MOV [7, A, B, C]:
if C is 0, move reg $A to mem B
if C is 1, move reg $A to reg $B
if C is 2, move mem A to mem B
if C is 3, move mem B to reg $A
8 OUT [8, A]: outputs the content of the OUT register on port $A
9 INP [9, A]: reads in from port $A, puts it in register IN
A LVT [0xA, A]: loads interrupt vector table, starting from memory A
B INC [0xB]: increment register A by 1
C DEC [0xC, A, B]: decrement register B by 1
D RET [0xD]: return from an interrupt handler
E INT [0xE, A]: call interrupt $A
F HLT [0xF]: halts CPU execution immediately
Interrupts
There are 2 ways of triggering interrupts. First is using the INT instruction, and the second is by having a device trigger one, or some sort of CPU exception happen.
With the interrupt table, it's a list of addresses to jump to for each interrupt. 16 consecutive memory locations, each of which hold an address.
There's 16 possible interrupts, some of which are reserved for errors or common devices, and the rest can be used for general purpose. (see table)
Interrupts #'s & their uses
0x0
Debug Exception
0x1
Invalid Opcode
0x2
Divide by Zero
0x3
Reserved
0x4
(Timer)
0x5
(Keyboard)
0x6
General Purpose
0x7
General Purpose
0x8
General Purpose
0x9
General Purpose
0xA
General Purpose
0xB
General Purpose
0xC
General Purpose
0xD
General Purpose
0xE
General Purpose
0xF
General Purpose
Stack
The stack grows upward in memory, it's a FILO/LIFO thing, and the stack pointer defaults to memory location 0x80. (128)
Registers
The SP and IP registers are the stack pointer and instruction pointer registers, respectively.
Registers A, B, C, & D are all general-purpose.
The IN and OUT registers are used for port IO, with the OUT instruction.
The register setup (for development) is as follows:
0
IP
1
SP
2
rA
3
rB
4
rC
5
rD
6
OUT
7
IN
Other useful info
The small input box at the top is for inputting programs, and you just have to type a string of numbers, then hit the "Enter" button or press the enter key. The middle, large black box is for program output. The beige-yellow colored box at the bottom is for logging and debug output.