UM012811-0904
Address
Space
eZ8 CPU
User Manual
19
rupt routines, the Stack Pointer must be set to prepare for possible Illegal Instruction
Traps.
The stack address decrements prior to a PUSH operation and increments after a POP oper-
ation. The stack address always points to the data stored at the top of the stack. The stack
is a return stack for interrupts and CALL and TRAP instructions. It can also be employed
as a data stack.
During a CALL instruction, the contents of the Program Counter are saved on the stack.
The Program Counter is restored during execution of a Return (RET). Interrupts and Traps
(either the TRAP instruction or an Illegal Instruction Trap) save the contents of the Pro-
gram Counter and the Flags Register on the stack. The Interrupt Return (IRET) instruction
restores them. Figure 7 illustrates the contents of the Stack and the location of the Stack
Pointer following Call, Interrupt and Trap operations.
Figure 7. Stack Operations
An overflow or underflow can occur when the stack address is incremented or decre-
mented beyond the available address space. The programmer must prevent this occurrence
or unpredictable operation will result.
PC[15:8]
PC[7:0]
Top of Stack
Flags
PC[15:8]
PC[7:0]
Top of Stack
Stack Contents
After an
Interrupt or Trap
Stack Contents
After a
Call Instruction