Z80 Registers
The Z80 contains 208 bits of memory that are available to the programmer as registers.
Register Set | Special Purpose Registers | ||||
---|---|---|---|---|---|
Main | Alternate | ||||
Accumulator | Flags | Accumulator | Flags | Interrupt Vector | Memory Refresh |
A | F | A' | F' | I | R |
B | C | B' | C' | Index Register IX | Index Register IY |
D | E | D' | E' | Stack Pointer SP | |
H | H | H' | L' | Program Counter PC |
Accumulator and Flag registers
The Z80 provides two independent 8-bit accumulators each with an associated flag register. The programmer can switch between the two pairs with the EX AF, AF' instruction.
General Purpose registers
Two matched sets of general purpose registers are available, each set containing six 8-bit registers: B, C, D, E, H and L.
These registers are also arranged to provide 3 16-bit registers: BC, DE and HL.
The HL register pair is usually used for addressing memory and has more instructions available to it for this purpose than BC or DE register pairs.
The programmer can switch between the main (BC, DE and HL) and alternate (BC', DE' and HL') set of general purpose registers with the EXX instruction.
PC Program Counter
The program counter holds the 16-bit address of the current instruction being fetched from memory. The Program Counter is automatically incremented after its contents are transferred to the address lines. When a program jump occurs, the new value is automatically placed in the Program Counter, overriding the incrementer.
SP Stack Pointer
The stack pointer holds the 16-bit address of the current top of a stack located anywhere in external system RAM. The external stack memory is organized as a last-in first-out (LIFO) file. Data can be pushed onto the stack using the PUSH instructions or popped off of the stack using the POP instructions.