s3c72m9 Samsung Semiconductor, Inc., s3c72m9 Datasheet - Page 30

no-image

s3c72m9

Manufacturer Part Number
s3c72m9
Description
The S3c72m5/s3c72m7/s3c72m9 Single-chip Cmos Microcontroller Has Been Designed For High Performance Using Samsung S
Manufacturer
Samsung Semiconductor, Inc.
Datasheet
ADDRESS SPACES
STACK OPERATIONS
STACK POINTER (SP)
The stack pointer (SP) is an 8-bit register that stores the address used to access the stack, an area of data memory
set aside for temporary storage of data and addresses. The SP can be read or written by 8-bit control instructions.
When addressing the SP, bit 0 must always remain cleared to logic zero.
There are two basic stack operations: writing to the top of the stack (push), and reading from the top of the stack
(pop). A push decrements the SP and a pop increments it so that the SP always points to the top address of the
last data to be written to the stack.
The program counter contents and program status word are stored in the stack area prior to the execution of a CALL
or a PUSH instruction, or during interrupt service routines. Stack operation is a LIFO (Last In-First Out) type. The
stack area is located in general-purpose data memory bank 0.
During an interrupt or a subroutine, the PC value and the PSW are saved to the stack area. When the routine has
completed, the stack pointer is referenced to restore the PC and PSW, and the next instruction is executed.
The SP can address stack registers in bank 0 (addresses 000H-0FFH) regardless of the current value of the enable
memory bank (EMB) flag and the select memory bank (SMB) flag. Although general-purpose register areas can be
used for stack operations, be careful to avoid data loss due to simultaneous use of the same register(s).
Since the reset value of the stack pointer is not defined in firmware, we recommend that you initialize the stack
pointer by program code to location 00H. This sets the first register of the stack area to 0FFH.
F
To initialize the stack pointer (SP):
1. When EMB = "1":
2. When EMB = "0":
2-14
F80H
F81H
A subroutine call occupies six nibbles in the stack; an interrupt requires six. When subroutine nesting
or interrupt routines are used continuously, the stack area should be set in accordance with the
maximum number of subroutine levels. To do this, estimate the number of nibbles that will be used for
the subroutines or interrupts and set the stack area correspondingly.
PROGRAMMING TIP — Initializing the Stack Pointer
SMB
LD
LD
LD
LD
SP3
SP7
15
EA,#00H
SP,EA
EA,#00H
SP,EA
SP2
SP6
SP1
SP5
NOTE
; Select memory bank 15
; Bit 0 of SP is always cleared to "0"
; Stack area initial address (0FFH)
; Memory addressing area (00H–7FH, F80H–FFFH)
SP4
"0"
S3C72M5/C72M7/C72M9/P72M9 (Preliminary Spec)
(SP) – 1

Related parts for s3c72m9