Samsung S3F80JB manual System and User Stacks, Stack Operations, Stack Pointers SPL

Models: S3F80JB

1 346
Download 346 pages 34.13 Kb
Page 52
Image 52

S3F80JB

ADDRESS SPACES

 

 

SYSTEM AND USER STACKS

S3C8-series microcontrollers use the system stack for subroutine calls and returns and to store data. The PUSH and POP instructions are used to control system stack operations. The S3F80JB architecture supports stack operations in the internal register file.

Stack Operations

Return addresses for procedure calls, interrupts and data are stored on the stack. The contents of the PC are saved to stack by a CALL instruction and restored by the RET instruction. When an interrupt occurs, the contents of the PC and the FLAGS registers are pushed to the stack. The IRET instruction then pops these values back to their original locations. The stack address value is always decreased by one before a push operation and increased by one 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-15.

Top of stack

PCL

PCH

Stack contents

after a call instruction

High Address

Top of

stack

Low Address

PCL

PCH

Flags

Stack contents

after an interrupt

Figure 2-16. 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)

Register location D9H contains the 8-bit stack pointer (SPL) that is used for system stack operations. After a reset, the SPL value is undetermined. Because only internal memory 256-byte is implemented in The S3F80JB, the SPL must be initialized to an 8-bit value in the range 00–FFH.

2-20

Page 52
Image 52
Samsung S3F80JB manual System and User Stacks, Stack Operations, Stack Pointers SPL