Instruction groups

November 5, 2021 · View on GitHub

Legend

SymbolMeaning
R88 bit register
R1616 bit register
i88 bit value
s8Signed 8 bit value
i1616 bit value
ccCondition code
RlistRegister list, such as BC/DE (BC and DE registers), BC-DL (BC, DE and HL), or a combination thereof

Condition codes

CodeMeaningAlternative
LESigned less than or equal
GTSigned greater than
LTSigned less than
GESigned greater than or equal
LEUUnsigned less than or equal
GTUUnsigned greater than
LTUUnsigned less thanC (carry)
GEUUnsigned greater than or equalNC (not carry)
EQEqualZ (zero)
NENot equalNZ (not zero)

Synthesized instructions

For improved quality of life, the assembler provides several synthesized instructions. This includes instructions such as LD FT,Label which would be cumbersome to write manually every time the programmer needed to load the address of a label. These instructions are marked as (synthesized) in the tables below.

All mnemonics may be followed by a condition code. The assembler will synthesize this into a J/CC (with the opposite condition CC) and the instruction.

For instance LD/EQ T,1 will load T with the value 1 if the flags in F satisfy the EQ condition.

Arithmetic

MnemonicOperationRemarks
ADD T,R8Add 8 bit register to T
ADD FT,R16Add 16 bit register to FT
ADD R8,i8Add immediate byte to 8 bit register
ADD R16,s8Add immediate signed byte to 16 bit register
ADD R16,i16Add immediate 16 bit value to 16 bit register(synthesized)
SUB T,R8Subtract 8 bit register from T
SUB FT,R16Subtract 16 bit register from FT
SUB R8,i8Subtract immediate byte from 8 bit register(synthesized)
SUB R16,s8Subtract immediate signed byte from 16 bit register(synthesized)
SUB R16,i16Subtract immediate 16 bit value from 16 bit register(synthesized)
EXT Sign extend T register
NEG TNegate T register
NEG FTNegate FT register

Bitwise

MnemonicOperationRemarks
AND T,R8Bitwise AND T with 8 bit register
AND T,i8Bitwise AND T register with immediate byte
OR T,R8Bitwise OR T with 8 bit register
OR T,i8Bitwise OR T register with immediate byte
XOR T,R8Bitwise XOR T with 8 bit register
XOR T,i8Bitwise XOR T register with immediate byte
LS FT,R8Left shift register FT by amount in 8 bit register
LS FT,i8Left shift register FT by immediate amount
RS FT,R8Right shift register FT by amount in 8 bit register
RS FT,i8Right shift register FT by immediate amount
RSA FT,R8Arithmetically right shift register FT by amount in 8 bit register
RSA FT,i8Arithmetically right shift register FT by immediate amount
NOT FSet F to one's complement of itself
NOT TSet T to one's complement of itself(synthesized)
NOT FTSet FT to one's complement of itself(synthesized)

Comparison

MnemonicOperationRemarks
CMP T,R8Set F to flags reflecting the result of T register minus 8 bit register
CMP R8,i8Set F to flags reflecting the result of 8 bit register minus immediate byte
CMP FT,R16Set F to flags reflecting the result of FT register minus 16 bit register
TST R16Set F to flags reflecting the result of 16 bit register minus zero

Program flow

MnemonicOperationRemarks
DJ R8,s8Decrement 8 bit register, if result is non-zero jump to PC + s8
J s8Jump to PC + s8
J (r16)Jump to address in 16 bit register
JAL (r16)Jump to address in 16 bit register and store return address in HL
JAL i16Jump to address in and store return address in HL(synthesized)
J/cc s8If register F satisfies the condition, jump to PC + s8
RETIReturn from an interrupt service routine
SYS i8Perform a system call to vector i8

Register transfer

MnemonicOperationRemarks
EXG T,R8Exchange contents of T with 8 bit register
EXG FT,R16Exchange contents of FT with 16 bit register
LD R8,i8Load 8 bit register with immediate byte
LD T,R8Load T register with contents of 8 bit register
LD R8,TLoad 8 bit register with contents of T
LD FT,R16Load FT register with contents of 16 bit register
LD R16,FTLoad 16 bit register with contents of FT
LD R16,i16Load 16 bit register with immediate 16 bit value(synthesized)
POP R16Pop contents of 16 bit register stack
POP RlistPop contents of specified 16 bit register stacks(synthesized)
POPAPop contents of all 16 bit registers stacks
PUSH R16Push contents of 16 bit register onto its stack
PUSH RlistPush contents of specified 16 bit registers onto their stacks(synthesized)
PUSHAPush contents of 16 bit registers onto their stacks
SWAP R16Swap two topmost register stack entries
SWAP RlistSwap two topmost stack entries for specified registers(synthesized)
SWAPASwap two topmost stack entries for all registers

External Memory and I/O

MnemonicOperationRemarks
LCO T,(R16)Load T with byte in code area pointed to by 16 bit register
LD T,(R16)Load T with byte in data area pointed to by 16 bit register
LD (R16),TStore T in data area pointed to by 16 bit register
LD R8,(FT)Load 8 bit register with byte in data area pointed to by FT
LD (FT),R8Store 8 bit register in data area pointed to by FT
LCR T,(C)Load T with contents of configuration register
LCR (C),TLoad configuration register with contents of T
LIO T,(R16)Load T with byte in I/O space pointed to by 16 bit register
LIO (R16),TStore T in I/O space pointed to by 16 bit register

System control

MnemonicOperationRemarks
DIDisable external interrupts
EIEnable external interrupts
NOPNo operation

Continue reading

Introduction and overview

Instruction groups

Opcode matrix

Alphabetical list of mnemonics

Configuration registers

Interrupts