S
un
pl
us
IT
C
on
fid
en
tia
l
F
or
A
D
D
In
te
rn
at
io
na
l L
im
ite
d
U
se
O
nl
y
CPU6502 Instruction Manual v2.1
Sunplus reserves the rights to change this documentation without prior notice.
09/13/2005
10
Stack
In normal use, stack can be used as storing return address, temporary data or register‘s
content. A stack has the property that the last item placed on the stack will be the first item
removed. This property is commonly referred to as last in, first out, or simply
LIFO
. A
diagram is shown as follows:
In push activity, a value of 30 is pushed first. Then, a value of 40 is pushed. Thus, the value
of 40 is now stored on the top on stack. After all values stored in the stack, the value order is
60, 50, 40, 30.
Now, in pop activity, the value of 60 will be popped out first. Second, the value of 50 will be
popped. Then, 40 and 30 will be popped out in order. Stack is empty after all the values are
popped.
50
50
40
40
40
30
30
30
30
Stack (Push)
Push 30
Push 40
Push 50
Push 60
60
50
40
40
30
30
30
Stack (Pop)
POP 60
POP 50
POP 40
POP 30