The instruction format is :
0MM0OOOO DDDDAAAA 0000BBBB 00000000
or (immediate mode)
0MM1OOO DDDDAAAA BBBBBBBB BBBBBBBB
MM is the Mode:[edit | edit source]
- 00b for IO
- 01b for ALU
- 10b for JUMP
- 11b for RAM
the A, B, D values are set or 0 depending on the operation. When applicable, DDDD is the destination register. AAAA and BBBB are source registers. In immediate mode, BBBBBBBB BBBBBBB is the immediate value.
In the following sections "B" designates either the value held by register BBBB if not in immediate mode, or the immediate value BBBBBBBB BBBBBBBB if in immediate mode. "A" designates the value held by register A.
OOOO is the opcode.[edit | edit source]
Its meaning depends on the mode
- In IO mode (MM = 00b):
- 0000b : nop. Does nothing.
- 0001b : in. Moves the value from Input to DDDD
- 0010b : out. Moves the value A to Output
- 0011b : keyboard. Moves the keyboard value to DDDD. The Keyboard value has format 0000000D VVVVVVVV, where D is 1 if the message is "key down", 0 if the message is "key up". VVVVVVVV is the value of the pressed or released key
- 0100b : screen. A maps to the screen parameter to set and B to the value to set this parameter to.
- 0101b: time_0. Moves the lower 32 bits of the Time component to DDDD and saves the upper bits for future retrieval.
- 0110b: time_1. Moves the upper 32 bits of the Time component (previously saved by the time_0 command) to DDDD.
- 0111b: counter. Moves the instruction counter value to DDDD
- In ALU mode (MM = 01b)
- 0000b: NAND A and B, put the result in D
- 0001b: OR A and B, put the result in D
- 0010b: AND A and B, put the result in D
- 0011b: NOR A and B, put the result in D
- 0100b: ADD A and B, put the result in D
- 0101b: SUB B to A, put the result in D (D = A - B)
- 0110b: XOR A and B, put the result in D
- 0111b: LSL A, B times, put the result in D (D = A << B)
- 1000b: LSR A, B times, put the result in D (D = A >> B)
- 1001b: ASR A, B times, put the result in D (D = A >> B)
- 1010b: CMP A and B and put the resulting flags in D
- In JUMP mode (MM = 10b), the register AAAA holds the flags compared to OOOO interpreted as flags. If the flags match (any two bits match), the counter is overriden by the value held by BBBB (or BBBBBBBB BBBBBBBB in immediate mode)
- In RAM mode (MM = 11b):
- 0000b: load_8. Load 1 byte from the RAM at address B and move it to register DDDD
- 0001b: load_16. Load 2 bytes from the RAM at address B and move it to register DDDD
- 0010b: load_32 Load 4 bytes from the RAM at address B and move it to register DDDD
- 0011b: pload. Load 4 bytes from the persistent storage at address B and move it to register DDDD
- 0100b: store_8. Store the lower byte of value A to the RAM at address B
- 0101b: store_16. Store the lower 2 bytes of value A to the RAM at address B
- 0110b: store_32. Store value A to the RAM at address B
- 0111b: pstore. Store value A to the persistent storage at address B