Z8® stacks, Stacks – Zilog Z86193 User Manual
Page 29

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
- Z86233 Z86243 Z86733 Z86743 Z86C02 Z86C04 Z86C08 Z86C15 Z86C21 Z86C30 Z86C31 Z86C33 Z86C36 Z86C40 Z86C43 Z86C61 Z86C62 Z86C63 Z86C65 Z86C83 Z86C90 Z86C91 Z86C93 Z86C96 Z86E02 Z86E03 Z86E04 Z86E06 Z86E07 Z86E08 Z86E15 Z86E21 Z86E30 Z86E31 Z86E33 Z86E34 Z86E40 Z86E43 Z86E44 Z86E61 Z86E63 Z86E83 Z86K15 Z86L02 Z86L04 Z86L08 Z86L16 Z8E000 Z8E001 Z8PE003