The Z80 Instruction Set

A B C D E H I J L N O P R S X

The lists contains all the normal machine code instructions for the microprocessor, plus a number of undocumented ones. The latter comprise those which operate on the high or low bytes of the Index registets (IX and lY) which are notated here as HIX, LIX, HIY and LIY - some assemblers may use the form IXH, etc - and a set of rotation instructions complementary to SRL, which are designated SLL.

The Opcodes and T states

Within the tables of instructions, a number of abbreviations are used:

ddisplacement (a value from -128 (&80) to +127 (&7F))
na single byte value (from 0 (&00) to 255 (&FF))
hiloa double byte value (from -32768 (&8000) via 0 to 32767 (&7FFF))
addran address value (from 0 (&0000) to 65535 (&FFFF))

(in the sequence of opcode bytes, `addr' and `hilo' are entered low byte first)

The next two columns detail the number of bytes applicable to each instruction, and the number of T states (clock pulses) that each requires - some have two figures which are distinguised as follows:

fmeans `the number of T states required when the condition is false'
tmeans `the number of T states needed when the condition is true'
=means `the number of T states needed when either BC=0 and/or A matches the contents of HL'
#means `the number of T states required when both the above conditions are false'
zmeans `the number of T states needed when B=0'
nzmeans `the number of T states requrred when B<>0'

The Flag Register

The last columns give the effect on the flag bits which each instruction causes:

?means the setting of the bit is unpredictable
-means the setting of the bit is unchanged
0means that the flag bit is reset to zero
1means that the flag bit is set to one.
POPmeans that the flag bit is determined by whatever is taken from the stack.
In addition, the Sign flag (bit 7) is also set:
7if bit 7 of the A register is set
15if bit 15 of the HL register pair (ie bit 7 of the H register) is set
=7if bit 7 of the A register would be set by subtraction in lieu of CP
The Zero flag (bi6 6) is also set:
zif the A register or the HL register pair equals zero
=if the A register matches the compared register or value
=Aif the A register matches the contents of the address pointed to by HL
<>Bif the B register holds zero
<>bif the bit tested is zero
The Parity/Overflow flag (bit 2) is also set:
pif the register concemed contains an even number of set bits
vif an overflow has occured in Two's Complement arithmetic
BCif BC is not zero
A80if the A register was &80 before this instruction was performed
ito the contents of the microprocessor's internal interrupt register
The Carry flag (bit 0) is also set:
cif an addition resulted in a carry out of bit 7 (for a register) or bit 15 (for a register pair)
bif a subtraction required a borrow from bit 7 (for a register) or bit 15 (for a register pair)
<if the A register is less than the value or register that is being compared
r0by the bit rotated in from bit 0 of the register concerned
r7by the bit rotated in from bit 7 of the register concerned
xif the Carry was reset (ie zero) before this instruction was performed
A0if tbe A register was &00 before this instruction was performed

The flag register is bit significant, and the bits are defined as follows:


David Cantrell, March 1996