Back to menu

CPU Registers



You can see the values in the different CPU registers or counters.

On the Z80, these registers or counters are called: A, B, C, D, E, F, H, L, IX, IY, SP, PC, I, R, IM, CLH, CLL, CNT.
There are also shadow registers : A', B', C', D', E', F', H', L', useful to swap values with the normal registers.

A is the accumulator, it's the most important register.

As the Z80 is an 8-bit processor, the A, B, C, D, E, H, L registers can hold any value from 0-255 (= 8 bit or one byte).
To store larger numbers, you can combine a few of them: BC, DE, HL. The result is a 16 bit register, having a range from 0-65535.

F is the flag register, it contains flags which store certain conditions after executing opcodes :

Z   zero flag (Z = zero flag set / NZ = not set)
C   carry flag (C = carry flag set / NC = not set)
P   parity flag (PE = even / PO = odd) also used as overflow flag
S   sign flag (P = plus / M = minus)

If you change the flags, you can see the result in the AF register.

I
is the interrupt register that contains the upperword of the interrupt table. Its flag indicates if the interrupts are enabled (EI) or disabled (DI)

IX
and IY are mostly used as auxiliary HL and can be used as index fields.

SP is the stackpointer, it's a very important register, though it's changed most of time indirectly by PUSHing/POPing values to/from the stack.

PC is a program counter, to keep track of where the Z80 is getting instructions from.

R is the memory refresh register. After each instruction, it'll be incremented. It can be used as a poor random number generator.

IM is the interrupt mode register. Value can be 0, 1 or 2.

CLH  is the high 16 bits of the CPU clock counter, CLL is the low 16 bits of the CPU clock counter (so the current clock counter is 65536 * CLH + CLL) and CNT  is an instruction counter. These values may come in handy while debugging.


Back to menu