Skip to content

Atom Appendices10

Appendix 10 — Z80 Instruction Reference

This searchable table covers the complete Z80 instruction-form families Atom claims and proves against its AZM byte oracle. It includes the documented Z80 instructions, classic index-half registers, SLL with its SLS alias and indexed CB forms with plain-register destinations.

The table omits firmware-specific ED aliases, extensions from other CPUs and cycle counts.

Status values used below:

  • documented is part of the standard documented Z80 set
  • documented prefix family is standard, but lives in CB, ED, DD, FD, DDCB or FDCB
  • undocumented but classic sits outside the original documented set, yet is widely supported and commonly treated as standard practice

The form column uses R for an encodable 8-bit register, RR, SS or PP for the register-pair set accepted by that instruction, N for an 8-bit value, NN for a 16-bit value, D for an index displacement, DISP for a relative target and CC for a condition code. In BIT, RES and SET, B means a bit number from 0 through 7.


MnemonicSupported classic formsPrefix familiesStatusNotes
ADCADC A,R, ADC A,N, ADC A,(HL), ADC A,(IX+D), ADC A,(IY+D), ADC HL,SSbase, DD, FD, EDdocumentedtwo separate families: 8-bit accumulator and 16-bit HL
ADDADD A,R, ADD A,N, ADD A,(HL), ADD A,(IX+D), ADD A,(IY+D), ADD HL,SS, ADD IX,PP, ADD IY,RRbase, DD, FDdocumented16-bit add always writes back to first pair
ANDAND R, AND N, AND (HL), AND (IX+D), AND (IY+D); optional explicit A first operandbase, DD, FDdocumentedaccumulator-only logical op
BITBIT B,R, BIT B,(HL), BIT B,(IX+D), BIT B,(IY+D)CB, DDCB, FDCBdocumented prefix familybit test, no stored result
CALLCALL NN, CALL CC,NNbasedocumentedabsolute subroutine call
CCFCCFbasedocumentedcomplement carry
CPCP R, CP N, CP (HL), CP (IX+D), CP (IY+D); optional explicit A first operandbase, DD, FDdocumentedcompare against A, flags only
CPDCPDEDdocumented prefix familyblock compare, decrement
CPDRCPDREDdocumented prefix familyrepeated CPD
CPICPIEDdocumented prefix familyblock compare, increment
CPIRCPIREDdocumented prefix familyrepeated CPI
CPLCPLbasedocumentedcomplement accumulator
DAADAAbasedocumentedBCD adjust after add/subtract
DECDEC R, DEC RR, DEC (HL), DEC (IX+D), DEC (IY+D), DEC IXH, DEC IXL, DEC IYH, DEC IYLbase, DD, FDdocumented plus undocumented-but-classic half-register formshalf-index-register forms are the undocumented part
DIDIbasedocumenteddisable interrupts
DJNZDJNZ DISPbasedocumentedrelative counted branch using B
EIEIbasedocumentedenable interrupts
EXEX DE,HL, EX AF,AF', EX (SP),HL, EX (SP),IX, EX (SP),IYbase, DD, FDdocumentedswap, not copy
EXXEXXbasedocumentedswaps BC/DE/HL with shadow set
HALTHALTbasedocumentedstop until interrupt
IMIM 0, IM 1, IM 2EDdocumented prefix familyinterrupt mode control
ININ A,(N), IN R,(C), IN (C)base, EDdocumented plus classic flags-only formthe operandless-destination form discards the byte and keeps its flag result
INCINC R, INC RR, INC (HL), INC (IX+D), INC (IY+D), INC IXH, INC IXL, INC IYH, INC IYLbase, DD, FDdocumented plus undocumented-but-classic half-register formshalf-index-register forms are the undocumented part
INDINDEDdocumented prefix familyblock input, decrement
INDRINDREDdocumented prefix familyrepeated IND
INIINIEDdocumented prefix familyblock input, increment
INIRINIREDdocumented prefix familyrepeated INI
JPJP NN, JP CC,NN, JP (HL), JP (IX), JP (IY)base, DD, FDdocumentedabsolute branch or indirect jump
JRJR DISP, JR NZ,DISP, JR Z,DISP, JR NC,DISP, JR C,DISPbasedocumentedshort relative branch only
LDregister/register, register/immediate, (HL) forms, (IX+D) / (IY+D) forms, A with (BC) / (DE), absolute memory forms, SP <- HL/IX/IY, I/R transfers, classic half-register forms and the AZM-compatible LD HL,DE / LD BC,DE expansionsbase, DD, FD, EDdocumented, classic-undocumented and two compatibility expansionsthe biggest family and the one with the most exceptions
LDDLDDEDdocumented prefix familyblock transfer, decrement
LDDRLDDREDdocumented prefix familyrepeated LDD
LDILDIEDdocumented prefix familyblock transfer, increment
LDIRLDIREDdocumented prefix familyrepeated LDI
NEGNEGEDdocumented prefix familyhistorically duplicated across several ED opcodes
NOPNOPbasedocumentedno operation
OROR R, OR N, OR (HL), OR (IX+D), OR (IY+D); optional explicit A first operandbase, DD, FDdocumentedaccumulator-only logical op
OTDROTDREDdocumented prefix familyrepeated block output, decrement
OTIROTIREDdocumented prefix familyrepeated block output, increment
OUTOUT (N),A, OUT (C),R, OUT (C),0base, EDdocumented plus classic zero-output formimmediate-port output takes its byte from A
OUTDOUTDEDdocumented prefix familyblock output, decrement
OUTIOUTIEDdocumented prefix familyblock output, increment
POPPOP BC, POP DE, POP HL, POP AF, POP IX, POP IYbase, DD, FDdocumentedword-sized only
PUSHPUSH BC, PUSH DE, PUSH HL, PUSH AF, PUSH IX, PUSH IYbase, DD, FDdocumentedword-sized only
RESRES B,R, RES B,(HL), RES B,(IX+D), RES B,(IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formsclassic CPUs commonly copy indexed result into target register
RETRET, RET CCbasedocumentedreturn from subroutine
RETIRETIEDdocumented prefix familyinterrupt return
RETNRETNEDdocumented prefix familyinterrupt/non-maskable return
RLRL R, RL (HL), RL (IX+D), RL (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy forms9-bit left rotation through carry: bit 7 → new C, old C → bit 0; updates S, Z, P/V, C
RLARLAbasedocumentedsame 9-bit left rotation as RL, accumulator only; C changes, H and N clear, S/Z/P/V unchanged
RLCRLC R, RLC (HL), RLC (IX+D), RLC (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formscircular left: bit 7 wraps to bit 0 and copies to C; updates S, Z, P/V, C
RLCARLCAbasedocumentedsame circular left rotation as RLC, accumulator only; C changes, H and N clear, S/Z/P/V unchanged
RLDRLDEDdocumented prefix familynibble rotate between A and (HL)
RRRR R, RR (HL), RR (IX+D), RR (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy forms9-bit right rotation through carry: bit 0 → new C, old C → bit 7; updates S, Z, P/V, C
RRARRAbasedocumentedsame 9-bit right rotation as RR, accumulator only; C changes, H and N clear, S/Z/P/V unchanged
RRCRRC R, RRC (HL), RRC (IX+D), RRC (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formscircular right: bit 0 wraps to bit 7 and copies to C; updates S, Z, P/V, C
RRCARRCAbasedocumentedsame circular right rotation as RRC, accumulator only; C changes, H and N clear, S/Z/P/V unchanged
RRDRRDEDdocumented prefix familynibble rotate between A and (HL)
RSTRST $00/$08/$10/$18/$20/$28/$30/$38basedocumentedfixed low-memory call vectors
SBCSBC A,R, SBC A,N, SBC A,(HL), SBC A,(IX+D), SBC A,(IY+D), SBC HL,SSbase, DD, FD, EDdocumentedtwo separate families: 8-bit accumulator and 16-bit HL
SCFSCFbasedocumentedset carry
SETSET B,R, SET B,(HL), SET B,(IX+D), SET B,(IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formssets bit and writes back
SLASLA R, SLA (HL), SLA (IX+D), SLA (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formsshift left: bit 7 → C, 0 fills bit 0; effectively multiply by 2; updates S, Z, P/V, C
SLL / SLSSLL R, SLL (HL), SLL (IX+D), SLL (IY+D), indexed result-copy formsCB, DDCB, FDCBundocumented but classicshift left with 1 filling bit 0 (result always odd); bit 7 → C; two common names for the same opcode
SRASRA R, SRA (HL), SRA (IX+D), SRA (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formsarithmetic right shift: bit 0 → C, bit 7 preserved (sign extension); correct for signed divide by 2; updates S, Z, P/V, C
SRLSRL R, SRL (HL), SRL (IX+D), SRL (IY+D), indexed result-copy formsCB, DDCB, FDCBdocumented prefix family plus undocumented-but-classic indexed result-copy formslogical right shift: bit 0 → C, 0 fills bit 7; correct for unsigned divide by 2; updates S, Z, P/V, C
SUBSUB R, SUB N, SUB (HL), SUB (IX+D), SUB (IY+D); optional explicit A first operandbase, DD, FDdocumentedaccumulator-only subtract
XORXOR R, XOR N, XOR (HL), XOR (IX+D), XOR (IY+D); optional explicit A first operandbase, DD, FDdocumentedaccumulator-only logical op

Notes On The Undocumented Forms Included Here

  • IXH, IXL, IYH, IYL in many 8-bit LD, INC, DEC, and ALU forms
  • SLL / SLS
  • DDCB / FDCB indexed rotate/shift/bit-result-copy forms such as RLC (IX+3),B

Rotate and Shift Instructions in Detail


Circular rotates: RLC / RLCA and RRC / RRCA

The byte rotates as a closed ring. The bit that falls off one end wraps to the other end, and a copy of it lands in the carry flag.

text
RLC / RLCA  (CIRCULAR ROTATE LEFT)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [B6 B5 B4 B3 B2 B1 B0 B7]   C = B7
  (BIT 7 WRAPS TO BIT 0; C RECEIVES A COPY OF B7)

RRC / RRCA  (CIRCULAR ROTATE RIGHT)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [B0 B7 B6 B5 B4 B3 B2 B1]   C = B0
  (BIT 0 WRAPS TO BIT 7; C RECEIVES A COPY OF B0)

Through-carry rotates: RL / RLA and RR / RRA

The carry flag is a ninth bit. The displaced bit exits through carry; the old carry enters on the other side.

text
RL / RLA  (ROTATE LEFT THROUGH CARRY)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = C
  AFTER:   [B6 B5 B4 B3 B2 B1 B0  C]   C = B7
  (OLD C ENTERS BIT 0; BIT 7 EXITS TO NEW C)

RR / RRA  (ROTATE RIGHT THROUGH CARRY)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = C
  AFTER:   [ C B7 B6 B5 B4 B3 B2 B1]   C = B0
  (OLD C ENTERS BIT 7; BIT 0 EXITS TO NEW C)

A left rotation through carry followed by a right rotation through carry recovers the original byte and carry. This makes RL/RR suitable for shifting multi-byte values because carry transfers the overflow bit between adjacent bytes.


Shifts: SLA, SRA, SRL, SLL/SLS

A shift discards the bit that falls off one end, after copying it to carry, and fills the vacated position with a fixed value. Rotates are the ones that wrap.

text
SLA  (SHIFT LEFT ARITHMETIC)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [B6 B5 B4 B3 B2 B1 B0  0]   C = B7
  (0 FILLS BIT 0; BIT 7 EXITS TO C; EQUIVALENT TO MULTIPLY BY 2)

SLL / SLS  (SHIFT LEFT LOGICAL, UNDOCUMENTED)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [B6 B5 B4 B3 B2 B1 B0  1]   C = B7
  (1 FILLS BIT 0; BIT 7 EXITS TO C; RESULT ALWAYS HAS BIT 0 SET)

SRA  (SHIFT RIGHT ARITHMETIC)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [B7 B7 B6 B5 B4 B3 B2 B1]   C = B0
  (BIT 7 PRESERVED, COPIED INTO ITSELF; BIT 0 EXITS TO C; SIGNED DIVIDE BY 2)

SRL  (SHIFT RIGHT LOGICAL)
  BEFORE:  [B7 B6 B5 B4 B3 B2 B1 B0]   C = ?
  AFTER:   [ 0 B7 B6 B5 B4 B3 B2 B1]   C = B0
  (0 FILLS BIT 7; BIT 0 EXITS TO C; UNSIGNED DIVIDE BY 2)

SRA copies bit 7 into itself while SRL clears it. SRA therefore preserves the sign and rounds negative odd values toward minus infinity: −4 ($FC) becomes −2 ($FE), while −3 ($FD) becomes −2 ($FE). SRL treats the same bits as an unsigned value.


Accumulator forms vs CB-prefix forms

FormExampleFlags updated
Accumulator-onlyRLCA, RRCA, RLA, RRAC changes; H and N clear; S, Z and P/V stay unchanged
CB-prefix (any register)RLC R, RRC R, RL R, RR RS, Z, P/V, C

RLCA, RRCA, RLA and RRA are single-byte base instructions, fast and compact.

RLC R, RRC R, RL R and RR R are CB-prefix forms. A zero test after a rotation, such as detecting when all bits have shifted out, requires the CB-prefix form rather than the accumulator shorthand.


Quick reference: what enters and exits each operation

InstructionBit enteringFromBit exitingTo
RLC / RLCAb7wraps from bit 7b7 copyC
RL / RLAold Centers bit 0b7new C
RRC / RRCAb0wraps from bit 0b0 copyC
RR / RRAold Centers bit 7b0new C
SLA0fills bit 0b7C
SLL / SLS1fills bit 0b7C
SRAb7preserved in placeb0C
SRL0fills bit 7b0C