Table of Contents

Advertisement

.75
P
Â

STACK

The stack always resides in the general purpose registers of the on-chip register file RAM. The stack pointer
register (SP) contains an address into the standard register file that is the address of the operand that is
currently on the top of the stack. The register 0FFH is the 8-bit stack pointer (SP), that is used for all stack
operations (see Figure 1-7).
Some devices prepend the lower nibble of register 0FEH to form a 12-bit stack pointer. Otherwise, register
0FEH is reserved.
0FEH
0FFH
Stack Address
Figure 1-7. Stack Pointer
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 stack is a return stack for CALL instruc-
tions and interrupts, as well as a data stack.
During a CALL instruction, the contents of the Program Counter are saved on the stack. The PC is restored
during a RET instruction. Interrupts cause the contents of the PC and FLAGS registers to be saved on the
stack. The IRET instruction restores them (see Figure 1-8).
An overflow or underflow can occur when the stack address is incremented or decremented during normal
stack operations. The programmer must prevent this occurrence or unpredictable operation may result. The
stack must not encroach into the control registers.

Advertisement

Table of Contents
loading

Table of Contents