
ADDRESS SPACES
S3C880A/F880A
2-26
SYSTEM AND USER STACKS
The S3C8-series microcontrollers use the system stack for subroutine calls and returns, interrupt processing, and
data storage. The PUSH and POP instructions support system stack operations. Stack operations in the internal
register file and in external data memory are supported by hardware. (The S3C880A/F880A do not support an
external memory access.) Bit 1 in the external memory timing register EMT selects an internal or external stack
area. The 16-bit stack pointer register (SPH, SPL) is used to access an externally defined system stack. An 8-bit
stack pointer (SPL) is sufficient for internal stack addressing.
Stack Operations
Return addresses for procedure calls and interrupts and data are stored on the stack. The contents of the PC are
saved to stack by a CALL instruction and restored by an RET instruction. When an interrupt occurs, the contents
of the PC and the FLAGS register are pushed to the stack. The IRET instruction then pops these values back to
their original locations. The stack address is always decremented before a push operation and incremented after
a pop operation. The stack pointer (SP) always points to the stack frame stored on the top of the stack, as shown
in Figure 2-16.
Low Address
High Address
Stack contects
after a call
instruction
Stack contects
after an
interrupt
Top of
stack
Flags
PCH
PCL
PCH
Top of
stack
Figure 2-17. Stack Operations
User-Defined Stacks
You can freely define stacks in the internal register file as data storage locations. The instructions, PUSHUI,
PUSHUD, POPUI, and POPUD, support user-defined stack operations.
Stack Pointers (SPL, SPH)
The register locations D8H and D9H contain the 16-bit stack pointer (SP) value. The most significant byte of a
16-bit stack address is stored in the SPH register (D8H) and the least significant byte is stored in the SPL register
(D9H). Because an external memory interface is not implemented for the S3C880A/F880A microcontrollers, a
single 8-bit stack pointer (SPL) is sufficient to address stack locations in the internal register file.
After a reset, the stack pointer value is undetermined. The SPL register must then be initialized to an 8-bit value
in the range 00H–FFH, page 0.
You can use the SPH register as a general-purpose data register. Please note that when you do so, data stored
in SPH may be overwritten if an overflow or underflow of the SPL register occurs during normal stack operations.
To prevent this, you can initialize the SPL value to FFH instead of 00H.