Skip to main content

Instruction format

Instructions can be 1 byte (8 bits) or 2 bytes (16 bits) depending on the instruction type. Arguments can be:
  • Register (r) - 4-bit register index (0R-15R)
  • Register pair (p) - 3-bit register pair index (0P-7P)
  • Number (n) - 4-bit immediate value
  • Address (a) - 12-bit address for jumps
  • Condition (c) - 4-bit condition code

Accumulator operations

Load and exchange

Syntax: LDM nLoads a 4-bit immediate value into the accumulator.
LDM 5      / Load 5 into accumulator
LDM 1111B  / Load binary 1111 (15) into accumulator
Syntax: LD rLoads the value from a register into the accumulator.
LD 0R   / Load register 0 into accumulator
LD 15R  / Load register 15 into accumulator
Syntax: XCH rSwaps the values of the accumulator and a register.
XCH 0R   / Swap accumulator with register 0
XCH 8R   / Swap accumulator with register 8

Arithmetic

Syntax: ADD rAdds a register to the accumulator with carry. Sets carry flag on overflow.
ADD 0R   / Add register 0 to accumulator
ADD 1R   / Add register 1 to accumulator (with carry from previous)
Syntax: SUB rSubtracts a register from the accumulator with borrow. Sets carry flag.
SUB 0R   / Subtract register 0 from accumulator
SUB 1R   / Subtract with borrow
Syntax: INC rIncrements a register by 1 (wraps on overflow).
INC 0R   / Increment register 0
INC 7R   / Increment register 7
Syntax: IACIncrements the accumulator by 1 (wraps on overflow).
IAC   / Accumulator = accumulator + 1
Syntax: DACDecrements the accumulator by 1 (wraps on underflow).
DAC   / Accumulator = accumulator - 1
Syntax: DAAAdjusts accumulator for BCD arithmetic. Adds 6 if accumulator > 9 or carry is set.
ADD 0R
DAA     / Adjust for BCD addition

Logical

Syntax: CMAInverts all bits in the accumulator (ones’ complement).
CMA   / Accumulator = ~accumulator
Syntax: CLBClears both the accumulator and carry flag to 0.
CLB   / Accumulator = 0, Carry = 0

Rotate

Syntax: RALRotates accumulator left through carry. Carry becomes bit 0, bit 3 becomes carry.
RAL   / Rotate left through carry
Syntax: RARRotates accumulator right through carry. Carry becomes bit 3, bit 0 becomes carry.
RAR   / Rotate right through carry

Register pair operations

Syntax: FIM p nLoads an 8-bit immediate value into a register pair (2 bytes).
FIM 0P 42    / Load 42 into register pair 0 (0R and 1R)
FIM 3P 255   / Load 255 into register pair 3 (6R and 7R)
FIM 0P 'A'   / Load ASCII 'A' into register pair 0
Syntax: FIN pFetches value from program memory using register pair 0 as index.
FIN 1P   / Fetch from (PC & 0xF00) | value_at(0P) into 1P
Syntax: SRC pSends a register pair as the address for subsequent memory operations.
SRC 0P   / Use register pair 0 as memory address
RDM      / Read from that address

Jump and call instructions

Syntax: JUN aUnconditional jump to a 12-bit address (2 bytes).
JUN START     / Jump to START label
JUN 0x100     / Jump to address 256
Syntax: JCN c aConditional jump to an 8-bit address within the current page (2 bytes).
JCN Z? LABEL    / Jump if accumulator is zero
JCN NZ? LABEL   / Jump if accumulator is not zero
JCN C? LABEL    / Jump if carry is set
JCN NC? LABEL   / Jump if carry is clear
JCN can only jump within the current 256-byte page. For cross-page jumps, use the LJCN macro.
Syntax: JIN pJump to address formed by current page and register pair value.
JIN 0P   / Jump to (PC & 0xF00) | value_at(0P)
Syntax: JMS aPushes return address to stack and jumps to a 12-bit address (2 bytes).
JMS SUBROUTINE   / Call subroutine
JMS 0x200        / Call at address 512
Syntax: BBL nReturns from subroutine and loads immediate value into accumulator.
BBL 0     / Return with accumulator = 0
BBL 5     / Return with accumulator = 5
Syntax: ISZ r aIncrements a register and jumps if result is NOT zero (2 bytes).
ISZ 0R LOOP   / Increment 0R, jump to LOOP if not zero

Memory operations

Data RAM

Syntax: WRMWrites accumulator to data RAM at address set by SRC.
SRC 0P   / Set address
WRM      / Write accumulator to data RAM
Syntax: RDMReads data RAM at address set by SRC into accumulator.
SRC 0P   / Set address
RDM      / Read from data RAM to accumulator
Syntax: ADMAdds data RAM value at SRC address to accumulator with carry.
SRC 0P
ADM      / Add memory value to accumulator
Syntax: SBMSubtracts data RAM value at SRC address from accumulator with borrow.
SRC 0P
SBM      / Subtract memory value from accumulator

Status RAM

Syntax: WR0 | WR1 | WR2 | WR3Writes accumulator to status character 0-3 at address set by SRC.
SRC 0P
WR0      / Write to status character 0
Syntax: RD0 | RD1 | RD2 | RD3Reads status character 0-3 at address set by SRC into accumulator.
SRC 0P
RD0      / Read status character 0

I/O operations

Syntax: WRRWrites accumulator to ROM port specified by SRC address.
SRC 0P
WRR      / Write to ROM port
Syntax: RDRReads from ROM port specified by SRC address into accumulator.
SRC 0P
RDR      / Read from ROM port
Syntax: WMPWrites accumulator to RAM port.
WMP      / Write to RAM port
Syntax: WPMWrites to program RAM (for self-modifying code).
WPM      / Write to program RAM

Carry operations

Syntax: CLCClears the carry flag to 0.
CLC      / Carry = 0
ADD 0R   / Add without previous carry
Syntax: STCSets the carry flag to 1.
STC      / Carry = 1
Syntax: CMCInverts the carry flag.
CMC      / Carry = ~Carry
Syntax: TCCCopies carry flag to accumulator and clears carry.
TCC      / Accumulator = Carry, Carry = 0
Syntax: TCSSets accumulator to 9 if carry=0, or 10 if carry=1, then clears carry.
TCS      / Accumulator = carry ? 10 : 9, Carry = 0

Special operations

Syntax: NOPDoes nothing. Used for timing or padding.
NOP      / No operation
Syntax: KBPConverts accumulator to bit position (0001→1, 0010→2, 0100→3, 1000→4, else→15).
KBP      / Convert bit to position
Syntax: DCLSelects RAM bank based on lower 3 bits of accumulator.
LDM 1
DCL      / Select RAM bank 1

Build docs developers (and LLMs) love