MC81F4x16
Stack Address (100H – 1FFH)
15
8 7
0
01H
SP
00H – 0FFH
Hardware fixed
Figure 9-3 Stack Pointer
Stack Pointer: Stack Pointer is an 8-bit register which indicates the current „push‟ point in the stack
area. It is used to push and pop when interrupts or general function call is occurred. Stack Pointer
identifies the location in the stack to be accessed (save or restore).
Generally, SP is automatically updated when a subroutine call is executed or an interrupt is accepted.
However, if it is used in excess of the stack area permitted by the data memory allocating
configuration, the user-processed data may be lost.
The stack can be located at any position within 100H to 1FFH of the internal data memory. The SP is
not initialized by hardware, requiring to write the initial value (the location with which the use of the
stack starts) by using the initialization routine. Normally, the initial value of “FFH” is used.
At execution of
A CALL/TCALL/PCALL
At execution
of RET instruction
At acceptance
of interrupt
At execution
of RETI instruction
01FF
01FE
01FD
01FC
PCH
PCL
01FF
01FE
01FD
01FC
PCH
PCL
01FF
01FE
01FD
01FC
PCH
PCL
PSW
01FF
PCH
PCL
PSW
Push
down
Pop
up
Push
down
Pop
up
01FE
01FD
01FC
SP befor
execution
01FF
01FD
01FD
01FF
01FF
01FC
01FC
01FF
SP after
exccution
At execution
Of PUSH instruction
PUSH A(X,Y,PSW)
At execution
Of POP instruction
POP A(X,Y,PSW)
01FF
0100
Stack
Depth
Push
down
Pop
up
01FF
01FE
01FD
01FC
A
01FF
01FE
01FD
01FC
A
SP befor
execution
01FF
01FE
01FF
01FE
SP after
exccution
Figure 9-4 Stack Operation
54
October 19, 2009 Ver.1.35