Z80 Processor Instructions

At the heart of the Spectrum (and many other computers, such as the Amstrad CPC, MSX, CP/M machines and the Gameboy) is the Zilog Z80A CPU, which runs at approximately 3.5MHz.

The instruction set is large and comprehensive, which can make it intimidating. However, once you start learning, you soon learn patterns and realise that it is made up of just a few types of command, most of which are either for arithmetic or loading values from processor registers or memory. Indeed, there are so many that there are several sets; in addition to the normal 256, you can access three further sets of 256 by adding one of three prefixes. Some of these are undocumented and can be unreliable or incompatible on different version of the CPU or on different machines.

If the instruction requires a prefix or arguments, it may be longer than one byte, and it is possible for a single instruction to be up to five bytes in length.

Each instruction takes a certain number of CPU cycles to run, depending on the complexity and whether memory or I/O ports need to be accessed. In the case of our table, some of this timing information is currently unavailable, and so the value has been left blank.

DecHexCharacterOpcodeLengthCyclesAfter CBLengthCyclesAfter DDFDCBLengthCyclesAfter EDLengthCycles
000Not usedNOP14RLC B18LD B, RLC (HL)10
101Not usedLD BC, ^310RLC C18LD C, RLC (HL)10
202Not usedLD BC, (A)17RLC D18LD D, RLC (HL)10
303Not usedINC BC16RLC E18LD E, RLC (HL)10
404Not usedINC B14RLC H18LD H, RLC (HL)10
505Not usedDEC B14RLC L18LD L, RLC (HL)10
606PRINT commaLD B, $27RLC (HL)115RLC (HL)115
707EDITRLCA14RLC A18LD A, RLC (HL)10
808EX AF, AF'14RRC B18LD B, RRC (HL)10
909ADD HL, BC111RRC C18LD C, RRC (HL)10
100ALD A, (BC)17RRC D18LD D, RRC (HL)10
110BDEC BC16RRC E18LD E, RRC (HL)10
120CDELETEINC C14RRC H18LD H, RRC (HL)10
130DENTERDEC C14RRC L18LD L, RRC (HL)10
140EnumberLD C, $27RRC (HL)115RRC (HL)115
150Fnot usedRRCA14RRC A18LD A, RRC (HL)10
1610INK controlDJNZ %213 / 8RL B18LD B, RL (HL)10
1711PAPER controlLD DE, ^310RL C18LD C, RL (HL)10
1812FLASH controlLD (DE), A17RL D18LD D, RL (HL)10
1913BRIGHT controlINC DE16RL E18LD E, RL (HL)10
2014INVERSE controlINC D14RL H18LD H, RL (HL)10
2115OVER controlDEC D14RL L18LD L, RL (HL)10
2216AT controlLD D, $27RL (HL)115RL (HL)115
2317TAB controlRLA14RL A18LD A, RL (HL)10
2418Not usedJR %212RR B18LD B, RR (HL)10
2519Not usedADD HL, DE111RR C18LD C, RR (HL)10
261ANot usedLD A, (DE)17RR D18LD D, RR (HL)10
271BNot usedDEC DE16RR E18LD E, RR (HL)10
281CNot usedINC E14RR H18LD H, RR (HL)10
291DNot usedDEC E14RR L18LD L, RR (HL)10
301ENot usedLD E, $27RR (HL)115RR (HL)115
311FNot usedRRA14RR A18LD A, RR (HL)10
3220spaceJR NZ, %212 / 7SLA B18LD B, SLA (HL)10
3321!LD HL, ^310SLA C18LD C, SLA (HL)10
3422"LD (^), HL316SLA D18LD D, SLA (HL)10
3523#INC HL16SLA E18LD E, SLA (HL)10
3624$INC H14SLA H18LD H, SLA (HL)10
3725%DEC H14SLA L18LD L, SLA (HL)10
3826&LD H, $27SLA (HL)115SLA (HL)115
3927,DAA14SLA A18LD A, SLA (HL)10
4028(JR Z, %212 / 7SRA B18LD B, SRA (HL)10
4129)ADD HL, HL111SRA C18LD C, SRA (HL)10
422A*LD HL, (^)316SRA D18LD D, SRA (HL)10
432B+DEC HL16SRA E18LD E, SRA (HL)10
442C,INC L14SRA H18LD H, SRA (HL)10
452D-DEC L14SRA L18LD L, SRA (HL)10
462E.LD L, $27SRA (HL)115SRA (HL)115
472F/CPL14SRA A18LD A, SRA (HL)10
48300JR NC, %212 / 7SLL B18LD B, SLL (HL)10
49311LD SP, ^310SLL C18LD C, SLL (HL)10
50322LD (^), A313SLL D18LD D, SLL (HL)10
51333INC SP16SLL E18LD E, SLL (HL)10
52344INC (HL)111SLL H18LD H, SLL (HL)10
53355DEC (HL)111SLL L18LD L, SLL (HL)10
54366LD (HL), $210SLL (HL)115SLL (HL)115
55377SCF14SLL A18LD A, SLL (HL)10
56388JR C, %212 / 7SRL B18LD B, SRL (HL)10
57399ADD HL, SP111SRL C18LD C, SRL (HL)10
583A:LD A, (^)313SRL D18LD D, SRL (HL)10
593B;DEC SP16SRL E18LD E, SRL (HL)10
603C<INC A14SRL H18LD H, SRL (HL)10
613D=DEC A14SRL L18LD L, SRL (HL)10
623E>LD A, $27SRL (HL)115SRL (HL)115
633F?CCF14SRL A18LD A, SRL (HL)10
6440@LD B, B14BIT 0, B18BIT 0, (HL)112IN B, (C)112
6541ALD B, C14BIT 0, C18BIT 0, (HL)112OUT (C), B112
6642BLD B, D14BIT 0, D18BIT 0, (HL)112SBC HL, BC115
6743CLD B, E14BIT 0, E18BIT 0, (HL)112LD (^), BC320
6844DLD B, H14BIT 0, H18BIT 0, (HL)112NEG18
6945ELD B, L14BIT 0, L18BIT 0, (HL)112RETN114
7046FLD B, (HL)17BIT 0, (HL)112BIT 0, (HL)112IM 018
7147GLD B, A14BIT 0, A18BIT 0, (HL)112LD I, A19
7248HLD C, B14BIT 1, B18BIT 1, (HL)112IN C, (C)112
7349ILD C, C14BIT 1, C18BIT 1, (HL)112OUT (C), C112
744AJLD C, D14BIT 1, D18BIT 1, (HL)112ADC HL, BC115
754BKLD C, E14BIT 1, E18BIT 1, (HL)112LD BC, (^)320
764CLLD C, H14BIT 1, H18BIT 1, (HL)112NEG18
774DMLD C, L14BIT 1, L18BIT 1, (HL)112RETN114
784ENLD C, (HL)17BIT 1, (HL)112BIT 1, (HL)112IM 018
794FOLD C, A14BIT 1, A18BIT 1, (HL)112LD R, A19
8050PLD D, B14BIT 2, B18BIT 2, (HL)112IN D, (C)112
8151QLD D, C14BIT 2, C18BIT 2, (HL)112OUT (C), D112
8252RLD D, D14BIT 2, D18BIT 2, (HL)112SBC HL, DE115
8353SLD D, E14BIT 2, E18BIT 2, (HL)112LD (^), DE320
8454TLD D, H14BIT 2, H18BIT 2, (HL)112NEG18
8555ULD D, L14BIT 2, L18BIT 2, (HL)112RETN114
8656VLD D, (HL)17BIT 2, (HL)112BIT 2, (HL)112IM 118
8757WLD D, A14BIT 2, A18BIT 2, (HL)112LD A, I19
8858XLD E, B14BIT 3, B18BIT 3, (HL)112IN E, (C)112
8959YLD E, C14BIT 3, C18BIT 3, (HL)112OUT (C), E112
905AZLD E, D14BIT 3, D18BIT 3, (HL)112ADC HL, DE115
915B[LD E, E14BIT 3, E18BIT 3, (HL)112LD DE, (^)320
925C/LD E, H14BIT 3, H18BIT 3, (HL)112NEG18
935D]LD E, L14BIT 3, L18BIT 3, (HL)112RETN114
945E^LD E, (HL)17BIT 3, (HL)112BIT 3, (HL)112IM 218
955F_LD E, A14BIT 3, A18BIT 3, (HL)112LD A, R19
9660ukpLD H, B14BIT 4, B18BIT 4, (HL)112IN H, (C)112
9761aLD H, C14BIT 4, C18BIT 4, (HL)112OUT (C), H112
9862bLD H, D14BIT 4, D18BIT 4, (HL)112SBC HL, HL115
9963cLD H, E14BIT 4, E18BIT 4, (HL)112LD (^), HL320
10064dLD H, H14BIT 4, H18BIT 4, (HL)112NEG18
10165eLD H, L14BIT 4, L18BIT 4, (HL)112RETN114
10266fLD H, (HL)17BIT 4, (HL)112BIT 4, (HL)112IM 018
10367gLD H, A14BIT 4, A18BIT 4, (HL)112RRD118
10468hLD L, B14BIT 5, B18BIT 5, (HL)112IN L, (C)112
10569iLD L, C14BIT 5, C18BIT 5, (HL)112OUT (C), L112
1066AjLD L, D14BIT 5, D18BIT 5, (HL)112ADC HL, HL115
1076BkLD L, E14BIT 5, E18BIT 5, (HL)112LD HL, (^)320
1086ClLD L, H14BIT 5, H18BIT 5, (HL)112NEG18
1096DmLD L, L14BIT 5, L18BIT 5, (HL)112RETN114
1106EnLD L, (HL)17BIT 5, (HL)112BIT 5, (HL)112IM 018
1116FoLD L, A14BIT 5, A18BIT 5, (HL)112RLD118
11270pLD (HL), B17BIT 6, B18BIT 6, (HL)112IN F, (C)112
11371qLD (HL), C17BIT 6, C18BIT 6, (HL)112OUT (C), 0112
11472rLD (HL), D17BIT 6, D18BIT 6, (HL)112SBC HL, SP115
11573sLD (HL), E17BIT 6, E18BIT 6, (HL)112LD (^), SP320
11674tLD (HL), H17BIT 6, H18BIT 6, (HL)112NEG18
11775uLD (HL), L17BIT 6, L18BIT 6, (HL)112RETN114
11876vHALT14BIT 6, (HL)112BIT 6, (HL)112IM 118
11977wLD (HL), A17BIT 6, A18BIT 6, (HL)112
12078xLD A, B14BIT 7, B18BIT 7, (HL)112IN A, (C)112
12179yLD A, C14BIT 7, C18BIT 7, (HL)112OUT (C), A112
1227AzLD A, D14BIT 7, D18BIT 7, (HL)112ADC HL, SP115
1237B{LD A, E14BIT 7, E18BIT 7, (HL)112LD SP, (^)320
1247C|LD A, H14BIT 7, H18BIT 7, (HL)112NEG18
1257D}LD A, L14BIT 7, L18BIT 7, (HL)112RETN114
1267E-LD A, (HL)17BIT 7, (HL)112BIT 7, (HL)112IM 218
1277F©LD A, A14BIT 7, A18BIT 7, (HL)112
12880ADD A, B14RES 0, B18LD B, RES 0, (HL)10
12981ADD A, C14RES 0, C18LD C, RES 0, (HL)10
13082ADD A, D14RES 0, D18LD D, RES 0, (HL)10
13183ADD A, E14RES 0, E18LD E, RES 0, (HL)10
13284ADD A, H14RES 0, H18LD H, RES 0, (HL)10
13385ADD A, L14RES 0, L18LD L, RES 0, (HL)10
13486ADD A, (HL)17RES 0, (HL)115RES 0, (HL)115
13587ADD A, A14RES 0, A18LD L, RES 0, (HL)10
13688ADC A, B14RES 1, B18LD B, RES 1, (HL)10
13789ADC A, C14RES 1, C18LD C, RES 1, (HL)10
1388AADC A, D14RES 1, D18LD D, RES 1, (HL)10
1398BADC A, E14RES 1, E18LD E, RES 1, (HL)10
1408CADC A, H14RES 1, H18LD H, RES 1, (HL)10
1418DADC A, L14RES 1, L18LD L, RES 1, (HL)10
1428EADC A, (HL)17RES 1, (HL)115RES 1, (HL)115
1438FADC A, A14RES 1, A18LD L, RES 1, (HL)10
14490(a)SUB A, B14RES 2, B18LD B, RES 2, (HL)10
14591(b)SUB A, C14RES 2, C18LD C, RES 2, (HL)10
14692(c)SUB A, D14RES 2, D18LD D, RES 2, (HL)10
14793(d)SUB A, E14RES 2, E18LD E, RES 2, (HL)10
14894(e)SUB A, H14RES 2, H18LD H, RES 2, (HL)10
14995(f)SUB A, L14RES 2, L18LD L, RES 2, (HL)10
15096(g)SUB A, (HL)17RES 2, (HL)115RES 2, (HL)115
15197(h)SUB A, A14RES 2, A18LD L, RES 2, (HL)10
15298(i)SBC A, B14RES 3, B18LD B, RES 3, (HL)10
15399(j)SBC A, C14RES 3, C18LD C, RES 3, (HL)10
1549A(k)SBC A, D14RES 3, D18LD D, RES 3, (HL)10
1559B(l)SBC A, E14RES 3, E18LD E, RES 3, (HL)10
1569C(m)SBC A, H14RES 3, H18LD H, RES 3, (HL)10
1579D(n)SBC A, L14RES 3, L18LD L, RES 3, (HL)10
1589E(o)SBC A, (HL)17RES 3, (HL)115RES 3, (HL)115
1599F(p)SBC A, A14RES 3, A18LD L, RES 3, (HL)10
160A0(q)AND A, B14RES 4, B18LD B, RES 4, (HL)10LDI116
161A1(r)AND A, C14RES 4, C18LD C, RES 4, (HL)10CPI116
162A2(s)AND A, D14RES 4, D18LD D, RES 4, (HL)10INI116
163A3(t)AND A, E14RES 4, E18LD E, RES 4, (HL)10OUTI116
164A4(u)AND A, H14RES 4, H18LD H, RES 4, (HL)10
165A5RNDAND A, L14RES 4, L18LD L, RES 4, (HL)10
166A6INKEY$AND A, (HL)17RES 4, (HL)115RES 4, (HL)115
167A7PIAND A, A14RES 4, A18LD L, RES 4, (HL)10
168A8FNXOR A, B14RES 5, B18LD B, RES 5, (HL)10LDD116
169A9POINTXOR A, C14RES 5, C18LD C, RES 5, (HL)10CPD116
170AASCREEN$XOR A, D14RES 5, D18LD D, RES 5, (HL)10IND116
171ABATTRXOR A, E14RES 5, E18LD E, RES 5, (HL)10OUTD116
172ACATXOR A, H14RES 5, H18LD H, RES 5, (HL)10
173ADTABXOR A, L14RES 5, L18LD L, RES 5, (HL)10
174AEVAL$XOR A, (HL)17RES 5, (HL)115RES 5, (HL)115
175AFCODEXOR A, A14RES 5, A18LD L, RES 5, (HL)10
176B0VALOR A, B14RES 6, B18LD B, RES 6, (HL)10LDIR121 / 16
177B1LENOR A, C14RES 6, C18LD C, RES 6, (HL)10CPIR121 / 16
178B2SINOR A, D14RES 6, D18LD D, RES 6, (HL)10INIR121 / 16
179B3COSOR A, E14RES 6, E18LD E, RES 6, (HL)10OTIR121 / 16
180B4TANOR A, H14RES 6, H18LD H, RES 6, (HL)10
181B5ASNOR A, L14RES 6, L18LD L, RES 6, (HL)10
182B6ACSOR A, (HL)17RES 6, (HL)115RES 6, (HL)115
183B7ATNOR A, A14RES 6, A18LD L, RES 6, (HL)10
184B8LNCP B14RES 7, B18LD B, RES 7, (HL)10LDDR121 / 16
185B9EXPCP C14RES 7, C18LD C, RES 7, (HL)10CPDR121 / 16
186BAINTCP D14RES 7, D18LD D, RES 7, (HL)10INDR121 / 16
187BBSORCP E14RES 7, E18LD E, RES 7, (HL)10OTDR121 / 16
188BCSGNCP H14RES 7, H18LD H, RES 7, (HL)10
189BDABSCP L14RES 7, L18LD L, RES 7, (HL)10
190BEPEEKCP (HL)17RES 7, (HL)115RES 7, (HL)115
191BFINCP A14RES 7, A18LD L, RES 7, (HL)10
192C0USRRET NZ111 / 5SET 0, B18LD B, SET 0, (HL)10
193C1STR$POP BC110SET 0, C18LD C, RES 0, (HL)10
194C2CHR$JP NZ, ^312 / 7SET 0, D18LD D, RES 0, (HL)10
195C3NOTJP ^310SET 0, E18LD E, RES 0, (HL)10
196C4BINCALL NZ, ^317 / 10SET 0, H18LD H, RES 0, (HL)10
197C5ORPUSH BC111SET 0, L18LD L, RES 0, (HL)10
198C6ANDADD A, $27SET 0, (HL)115RES 0, (HL)115
199C7<=RST 00111SET 0, A18LD L, RES 0, (HL)10
200C8>=RET Z111 / 5SET 1, B18LD B, RES 1, (HL)10
201C9<>RET110SET 1, C18LD C, RES 1, (HL)10
202CALINEJP Z, ^312 / 7SET 1, D18LD D, RES 1, (HL)10
203CBTHEN0SET 1, E18LD E, RES 1, (HL)10
204CCTOCALL Z, ^317 / 10SET 1, H18LD H, RES 1, (HL)10
205CDSTEPCALL ^317SET 1, L18LD L, RES 1, (HL)10
206CEDEF FNADC A, $27SET 1, (HL)115RES 1, (HL)115
207CFCATRST 08111SET 1, A18LD L, RES 1, (HL)10
208D0FORMATRET NC111 / 5SET 2, B18LD B, RES 2, (HL)10
209D1MOVEPOP DE110SET 2, C18LD C, RES 2, (HL)10
210D2ERASEJP NC, ^312 / 7SET 2, D18LD D, RES 2, (HL)10
211D3OPEN #OUT ($), A211SET 2, E18LD E, RES 2, (HL)10
212D4CLOSE #CALL NC, ^317 / 10SET 2, H18LD H, RES 2, (HL)10
213D5MERGEPUSH DE111SET 2, L18LD L, RES 2, (HL)10
214D6VERIFYSUB $27SET 2, (HL)115RES 2, (HL)115
215D7BEEPRST 10111SET 2, A18LD L, RES 2, (HL)10
216D8CIRCLERET C111 / 5SET 3, B18LD B, RES 3, (HL)10
217D9INKEXX14SET 3, C18LD C, RES 3, (HL)10
218DAPAPERJP C, ^312 / 7SET 3, D18LD D, RES 3, (HL)10
219DBFLASHIN A, ($)211SET 3, E18LD E, RES 3, (HL)10
220DCBRIGHTCALL C, ^317 / 10SET 3, H18LD H, RES 3, (HL)10
221DDINVERSE0SET 3, L18LD L, RES 3, (HL)10
222DEOVERSBC A, $27SET 3, (HL)115RES 3, (HL)115
223DFOUTRST 18111SET 3, A18LD L, RES 3, (HL)10
224E0LPRINTRET PO111 / 5SET 4, B18LD B, RES 4, (HL)10
225E1LLISTPOP HL110SET 4, C18LD C, RES 4, (HL)10
226E2STOPJP PO, ^312 / 7SET 4, D18LD D, RES 4, (HL)10
227E3READEX (SP), HL119SET 4, E18LD E, RES 4, (HL)10
228E4DATACALL PO, ^317 / 10SET 4, H18LD H, RES 4, (HL)10
229E5RESTOREPUSH HL111SET 4, L18LD L, RES 4, (HL)10
230E6NEWAND $27SET 4, (HL)115RES 4, (HL)115
231E7BORDERRST 20111SET 4, A18LD L, RES 4, (HL)10
232E8CONTINUERET PE111 / 5SET 5, B18LD B, RES 5, (HL)10
233E9DIMJP HL14SET 5, C18LD C, RES 5, (HL)10
234EAREMJP PE, ^312 / 7SET 5, D18LD D, RES 5, (HL)10
235EBFOREX DE, HL14SET 5, E18LD E, RES 5, (HL)10
236ECGO TOCALL PE, ^317 / 10SET 5, H18LD H, RES 5, (HL)10
237EDGO SUB0SET 5, L18LD L, RES 5, (HL)10
238EEINPUTXOR $27SET 5, (HL)115RES 5, (HL)115
239EFLOADRST 28111SET 5, A18LD L, RES 5, (HL)10
240F0LISTRET P111 / 5SET 6, B18LD B, RES 6, (HL)10
241F1LETPOP AF110SET 6, C18LD C, RES 6, (HL)10
242F2PAUSEJP P, ^312 / 7SET 6, D18LD D, RES 6, (HL)10
243F3NEXTDI14SET 6, E18LD E, RES 6, (HL)10
244F4POKECALL P, ^317 / 10SET 6, H18LD H, RES 6, (HL)10
245F5PRINTPUSH AF111SET 6, L18LD L, RES 6, (HL)10
246F6PLOTOR $27SET 6, (HL)115RES 6, (HL)115
247F7RUNRST 30111SET 6, A18LD L, RES 6, (HL)10
248F8SAVERET M111 / 5SET 7, B18LD B, RES 7, (HL)10
249F9RANDOMIZELD SP, HL16SET 7, C18LD C, RES 7, (HL)10
250FAIFJP M, ^312 / 7SET 7, D18LD D, RES 7, (HL)10
251FBCLSEI14SET 7, E18LD E, RES 7, (HL)10
252FCDRAWCALL M, ^317 / 10SET 7, H18LD H, RES 7, (HL)10
253FDCLEARFDOP0SET 7, L18LD L, RES 7, (HL)10
254FERETURNCP $27SET 7, (HL)115RES 7, (HL)115
255FFCOPYRST 38111SET 7, A18LD L, RES 7, (HL)10

Key
^    16-bit number (two bytes)
$    8-bit number (one byte)
%    2s comp offset (1 byte)

You can also download a version in Microsoft Excel format – Z80 instruction set with mnemonics, length and timing.

Credit for the information needs to go to Time Proofing and MSX Assembly Page. All information regarding the Z80 family of CPUs is copyright of Zilog.