Instruction Set

Op Code Top Nibble (hex) Addressing Modes (hex) Flags Example
PSH 3 9: reg   PSH Reg B -> 39 01
POP 4 9: reg Z POP Reg C -> 49 02
TRAP 5 0: see os doc   TRAP CLEAR_SCREEN -> 50 04
HALT 6 0: none   HALT -> 60
JSR 7 1: abs   JSR #1280 -> 71 12 80
RTN 8 0: none   RTN -> 80
JMP 9 1: abs   JMP #1280 -> 91 12 80
MOV A 2: reg, reg
3: (reg), reg
4: reg, (reg)
5: (reg), (reg)
6: abs, reg
7: (abs), reg
8: reg, (abs)
Z MOV Reg A, Reg B -> A2 00 01
MOV (Reg A), Reg B -> A3 00 01
MOV Reg A, (Reg B) -> A4 00 01
MOV (Reg A), (Reg B) -> A5 00 01
MOV #1234, Reg B -> A6 12 34 01
MOV (#1234), Reg B -> A7 12 34 01
MOV Reg B, (#1234) -> A8 01 12 34
ADC B 2: reg, reg
6: abs, reg
Z C ADC Reg A, Reg B -> B2 00 01
ADC #1234, Reg B -> B6 12 34 01
BNE C 1: abs   BNE #FFF0 -> C1 FF F0
BEQ D 1: abs   BEQ #FFF0 -> D1 FF F0
AND E 2: reg, reg
6: abs, reg
Z AND Reg A, Reg B -> E2 00 01
AND #00FF, Reg B -> E6 00 FF 01
XOR F 2: reg, reg
6: abs, reg
Z XOR Reg A, Reg B -> F2 00 01
XOR #FFFF, Reg B -> F6 FF FF 01

Push

Push the specified register onto the stack.

Op Code: PSH
Hex Code: 39
Function:
   SP = SP - 2
   (SP) = reg x

Example:
   PSH Reg A -> 39 00


Pop

Pop the specified register off of the stack.

Op Code: POP
Hex Code: 49
Function:
   reg x = (SP)
   SP = SP + 2

Example:
   POP Reg A -> 49 00


Trap

Call operating system function. For specific calls and their requirements, see os doc.

Op Code: TRAP
Hex Code: 50
Function:
   dependent on trap called

Example:
   TRAP SCROLL_LEFT -> 50 01


Halt

If sign board is in the free running mode, stop running.

Op Code: HALT
Hex Code: 60
Example:
   HALT -> 60


Jump to Subroutine

Jump to a subroutine. Push the return address onto the stack. Stack must be initialized by setting the SP to point to a predetermined section of memory.

Op Code: JSR
Hex Code: 71
Function:
   SP = SP - 2
   (SP) = PC
   PC = #abs

Example:
   JSR #1000 -> 71 10 00


Return from Subroutine

Return from a subroutine by popping the address from the stack into the program counter.

Op Code: RTN
Hex Code: 80
Function:
   PC = (SP)
   SP = SP + 2

Example:
   RTN -> 80


Jump

Jump to a specified location (absolute) in the memory.

Op Code: JMP
Hex Code: 91
Function:
   PC = #abs

Example:
   JMP #1000 -> 91 10 00


Move

Move data from one location to another.

Op Code: MOV

Hex Code: A2 - MOV reg x, reg y
Function:
   reg y = reg x

Example:
   MOV Reg C, Reg B -> A2 02 01

Hex Code: A3 - MOV (reg x), reg y
Function:
   reg y = (reg x)

Example:
   MOV (Reg C), Reg B -> A3 02 01

Hex Code: A4 - MOV reg x, (reg y)
Function:
   (reg y) = reg x

Example:
   MOV Reg C, (Reg B) -> A4 02 01

Hex Code: A5 - MOV (reg x), (reg y)
Function:
   (reg y) = (reg x)

Example:
   MOV (Reg C), (Reg B) -> A5 02 01

Hex Code: A6 - MOV #abs, reg y
Function:
   reg y = #abs

Example:
   MOV #1234, Reg B -> A6 12 34 01

Hex Code: A7 - MOV (#abs), reg y
Function:
   reg y = (#abs)

Example:
   MOV (#1234), Reg B -> A7 12 34 01

Hex Code: A8 - MOV reg x, (#abs)
Function:
   (#abs) = reg x

Example:
   MOV Reg B, (#1234) -> A8 01 12 34


Add

Add value to another. (Carry is not yet implemented)

Op Code: ADC

Hex Code: B2 - ADC reg x, reg y
Function:
   reg y = reg y + reg x

Example:
   ADC Reg C, Reg B -> B2 02 01

Hex Code: B6 - ADC #abs, reg y
Function:
   reg y = reg y + #abs

Example:
   ADC #1234, Reg B -> B6 12 34 01


Branch If Not Equal to Zero

Branch to a specified location (relative) in the memory if the zero flag is not set.

Op Code: BNE
Hex Code: C1
Function:
   PC = PC + #abs (if Z = 0)

Example:
   BNE #FFF0 -> C1 FF F0


Branch If Equal to Zero

Branch to a specified location (relative) in the memory if the zero flag is set.

Op Code: BEQ
Hex Code: D1
Function:
   PC = PC + #abs (if Z = 1)

Example:
   BEQ #FFF0 -> D1 FF F0


Bitwise AND

AND together all corresponding bits in given data.

Op Code: AND

Hex Code: E2 - AND reg x, reg y
Function:
   reg y = reg y & reg x

Example:
   AND Reg C, Reg B -> E2 02 01

Hex Code: E6 - AND #abs, reg y
Function:
   reg y = reg y + #abs

Example:
   AND #1234, Reg B -> E6 12 34 01


Bitwise XOR

Exclusive OR together all corresponding bits in given data.

Op Code: XOR

Hex Code: F2 - XOR reg x, reg y
Function:
   reg y = reg y ^ reg x

Example:
   AND Reg C, Reg B -> E2 02 01

Hex Code: F6 - XOR #abs, reg y
Function:
   reg y = reg y ^ #abs

Example:
   XOR #1234, Reg B -> E6 12 34 01