SN8P1829
8-Bit MCU build-in 12-bit ADC + PGIA + Charge-pump Reg 128 dots LCD driver
SONiX TECHNOLOGY CO., LTD
Page 30
Version 1.0
STACK OPERATION EXAMPLE
The two kinds of Stack-Save operations to reference the stack pointer (STKP) and write the program counter contents
(PC) into the stack buffer are CALL instruction and interrupt service. Under each condition, the STKP is decreased and
points to the next available stack location. The stack buffer stores the program counter about the op-code address. The
Stack-Save operation is as following table.
STKP Register
Stack Buffer
Stack Level
STKPB3 STKPB2 STKPB1 STKPB0 High
Byte
Low
Byte
Description
0
1 1 1 1
STK0H
STK0L
-
1
1 1 1 0
STK1H
STK1L
-
2
1 1 0 1
STK2H
STK2L
-
3
1 1 0 0
STK3H
STK3L
-
4
1 0 1 1
STK4H
STK4L
-
5
1 0 1 0
STK5H
STK5L
-
6
1 0 0 1
STK6H
STK6L
-
7
1 0 0 0
STK7H
STK7L
-
>8
- - - - - -
Stack Overflow
Table 3-1. STKP, STK
N
H and STK
N
L relative of Stack-Save Operation
There is a Stack-Restore operation corresponding each push operation to restore the program counter (PC). The RETI
instruction is for interrupt service routine. The RET instruction is for CALL instruction. When a Stack-Restore operation
executes the STKP increases and points to the next free stack location. The stack buffer restores the last program
counter (PC) to the program counter registers. The Stack-Restore operation is as following table.
STKP Register
Stack Buffer
Stack Level
STKPB3 STKPB2 STKPB1 STKPB0 High
Byte
Low
Byte
Description
7
1 0 0 0
STK7H
STK7L
-
6
1 0 0 1
STK6H
STK6L
-
5
1 0 1 0
STK5H
STK5L
-
4
1 0 1 1
STK4H
STK4L
-
3
1 1 0 0
STK3H
STK3L
-
2
1 1 0 1
STK2H
STK2L
-
1
1 1 1 0
STK1H
STK1L
-
0
1 1 1 1
STK0H
STK0L
-
Table 3-2. STKP, STK
N
H and STK
N
L relative of Stack-Restore Operation