Z8
®
CPU
User Manual
UM001604-0108
Address Space
22
Z8
®
Stacks
Stack operations can occur in either the Z8 Standard Register File or external data mem-
ory. Under software control, Port 0–1 Mode register (
F8h
) selects the stack location. Only
the General-Purpose Registers can be used for the stack when the internal stack is
selected.
The register pair
FEh
and
FFh
form the 16-bit Stack Pointer (SP), that is used for all stack
operations. The stack address is stored with the MSB in
FEh
and LSB in
FFh
, see
.
The stack address is decremented prior to a PUSH operation and incremented after a POP
operation. The stack address always points to the data stored on the top of the stack. The
Z8 CPU stack is a return stack for CALL instructions and interrupts, as well as a data
stack.
During a CALL instruction, the contents of the PC are saved on the stack. The PC is
restored during a RETURN instruction. Interrupts cause the contents of the PC and Flag
registers to be saved on the stack. The IRET instruction restores them (see
page 23).
When the Z8 CPU is configured for an internal stack (using the Z8 Standard Register
File), register
FFh
serves as the Stack Pointer. The value in
FEh
is ignored.
FEh
can be
used as a general-purpose register in this case only.
An overflow or underflow can occur when the stack address is incremented or decre-
mented during normal stack operations. The programmer must prevent this occurrence, or
unpredictable operation happens.
Figure 10. Stack Pointer
UPPER Byte
LOWER Byte
Stack Pointer High
FFh
Stack Pointer Low
FEh