Beruflich Dokumente
Kultur Dokumente
BE/LE:
More Info
Prepared by: Siti Fatimah
Nor Binti Ab Wahab
http://
www.cs.umd.edu/class/sum2003/cmsc311/Notes/M
ips/stack.html
http://
whatis.techtarget.com/definition/stack-pointer
http://
stackoverflow.com/questions/1464035/what-is-a-stack-pointer
-used-for-in-microprocessors
Prepared by: Siti Fatimah Nor Binti Ab Wahab
Software Stack
An area in RAM for temporary storage of data and
registers contents.
Building this stack is an inherent part of the interrupt
signal. However, stack can also be built
independently of an interrupt request. In fact, stacks
are used just about any time a subroutine is called.
The software stack is almost unlimited in size and
can reside anywhere in memory.
This implementation causes the need for a special
register in the microprocessor called the stack
pointer register.
Hardware Stack
A
Functions of stacks
1.
2.
3.
4.
Stack building
Stack operation
1.
push
2.
pop
11
Stack Example #1
Given the segment of the program and content of registers
(address and data are given in hexadecimal) below:
PUSH AX;
PUSH BX;
PUSH CX; (A)
POPBX;
POPAX;
PUSH DX;
POPCX;
(B)
AX = 1234, BX = 5678, CX= 9ABC, DX=DEFF
stack pointer register = 10FF
Prepared by: Siti Fatimah Nor Binti Ab Wahab
12
Stack Example #1
a)
b)
c)
13
AX;
BX;
CX;
(A)
AX = 1234
BX = 5678
CX = 9ABC
DX = DEFF
stack pointer register = 10FF
SP 10F9
BC
10FA
9A
10FB
78
10FC
56
10FD
34
10FE
12
10FF
XX
14
BX;
AX;
DX;
CX;
DX = DEFF
SP 10FD
34
10FE
12
(A)
BX = 9ABC
AX = 5678
CX = DEFF
15
16
Stack Example #2
Given
AX
BX
CX
DX
PC
=
=
=
=
=
1234
0BA79
1111
2B34
1003
AX
BX
CX
DX
PC
17
18
19
SP FFF3
03
FFF4
10
FFF5
34
FFF6
2B
FFF7
79
FFF8
BA
FFF9
34
FFFA
12
20
34
FFF6
2B
FFF7
79
SP FFF7
79
FFF8
BA
FFF8
BA
FFF9
34
FFF9
34
SP FFF9
34
FFFA
12
FFFA
12
FFFA
12
AX =
1003
CX =
2B34
DX =
BA79
Prepared by: Siti Fatimah Nor Binti Ab Wahab
21
Big endian
Little endian
22
Little Endian
23
Big Endian
24
25
Example 1(a)
Given
The
Content
AX
22FF
MOV [8002], AX
26
Memory Address
8002
LO
8003
HI
HI
LO
22
FF
Content
22
FF
27
LO
22
FF
Memory Address
8002
LO
8003
HI
Content
FF
22
28
29