<s>
A	O
stack	B-General_Concept
register	I-General_Concept
is	O
a	O
computer	O
central	O
processor	B-General_Concept
register	I-General_Concept
whose	O
purpose	O
is	O
to	O
keep	O
track	O
of	O
a	O
call	B-General_Concept
stack	I-General_Concept
.	O
</s>
<s>
On	O
an	O
accumulator-based	B-General_Concept
architecture	I-General_Concept
machine	O
,	O
this	O
may	O
be	O
a	O
dedicated	O
register	O
.	O
</s>
<s>
On	O
a	O
machine	O
with	O
mulitple	O
general-purpose	O
registers	O
,	O
it	O
may	O
be	O
a	O
register	O
that	O
is	O
reserved	O
by	O
convention	O
,	O
such	O
as	O
on	O
the	O
IBM	B-Application
System/360	I-Application
through	O
z/Architecture	B-Device
architecture	O
and	O
RISC	B-Architecture
architectures	I-Architecture
,	O
or	O
it	O
may	O
be	O
a	O
register	O
that	O
procedure	O
call	O
and	O
return	O
instructions	O
are	O
hardwired	O
to	O
use	O
,	O
such	O
as	O
on	O
the	O
PDP-11	B-Device
,	O
VAX	B-Device
,	O
and	O
Intel	B-Operating_System
x86	I-Operating_System
architectures	O
.	O
</s>
<s>
Some	O
designs	O
such	O
as	O
the	O
Data	B-Device
General	I-Device
Eclipse	I-Device
had	O
no	O
dedicated	O
register	O
,	O
but	O
used	O
a	O
reserved	O
hardware	O
memory	O
address	O
for	O
this	O
function	O
.	O
</s>
<s>
Machines	O
before	O
the	O
late	O
1960ssuch	O
as	O
the	O
PDP-8	B-Device
and	O
HP	O
2100did	O
not	O
have	O
compilers	O
which	O
supported	O
recursion	O
.	O
</s>
<s>
While	O
this	O
is	O
simpler	O
than	O
maintaining	O
a	O
stack	B-Application
,	O
since	O
there	O
is	O
only	O
one	O
return	O
location	O
per	O
subroutine	O
code	O
section	O
,	O
there	O
cannot	O
be	O
recursion	O
without	O
considerable	O
effort	O
on	O
the	O
part	O
of	O
the	O
programmer	O
.	O
</s>
<s>
A	O
stack	B-Application
machine	I-Application
has	O
2	O
or	O
more	O
stack	B-General_Concept
registers	I-General_Concept
one	O
of	O
them	O
keeps	O
track	O
of	O
a	O
call	B-General_Concept
stack	I-General_Concept
,	O
the	O
other(s )	O
keep	O
track	O
of	O
other	O
stack(s )	O
.	O
</s>
<s>
In	O
8086	B-General_Concept
,	O
the	O
main	O
stack	B-General_Concept
register	I-General_Concept
is	O
called	O
stack	B-Application
pointer	O
-	O
SP	O
.	O
</s>
<s>
register	O
(	O
SS	O
)	O
is	O
usually	O
used	O
to	O
store	O
information	O
about	O
the	O
memory	B-General_Concept
segment	I-General_Concept
that	O
stores	O
the	O
call	B-General_Concept
stack	I-General_Concept
of	O
currently	O
executed	O
program	O
.	O
</s>
<s>
SP	O
points	O
to	O
current	O
stack	B-Application
top	O
.	O
</s>
<s>
By	O
default	O
,	O
the	O
stack	B-Application
grows	O
downward	O
in	O
memory	O
,	O
so	O
newer	O
values	O
are	O
placed	O
at	O
lower	O
memory	O
addresses	O
.	O
</s>
<s>
To	O
push	O
a	O
value	O
to	O
the	O
stack	B-Application
,	O
the	O
PUSH	O
instruction	O
is	O
used	O
.	O
</s>
<s>
To	O
pop	O
a	O
value	O
from	O
the	O
stack	B-Application
,	O
the	O
POP	O
instruction	O
is	O
used	O
.	O
</s>
<s>
This	O
means	O
that	O
current	O
stack	B-Application
top	O
is	O
the	O
physical	O
address	O
0x1F820	O
(	O
this	O
is	O
due	O
to	O
memory	B-General_Concept
segmentation	I-General_Concept
in	O
8086	B-General_Concept
)	O
.	O
</s>
<s>
These	O
first	O
instruction	O
shall	O
push	O
the	O
value	O
stored	O
in	O
AX	O
(	O
16-bit	O
register	O
)	O
to	O
the	O
stack	B-Application
.	O
</s>
<s>
Usually	O
,	O
the	O
running	O
program	O
pushes	O
registers	O
to	O
the	O
stack	B-Application
to	O
make	O
use	O
of	O
the	O
registers	O
for	O
other	O
purposes	O
,	O
like	O
to	O
call	O
a	O
routine	O
that	O
may	O
change	O
the	O
current	O
values	O
of	O
registers	O
.	O
</s>
<s>
To	O
restore	O
the	O
values	O
stored	O
at	O
the	O
stack	B-Application
,	O
the	O
program	O
shall	O
contain	O
machine	O
instructions	O
like	O
this	O
:	O
</s>
<s>
Simpler	O
processors	O
store	O
the	O
stack	B-Application
pointer	O
in	O
a	O
regular	O
hardware	B-General_Concept
register	I-General_Concept
and	O
use	O
the	O
arithmetic	B-General_Concept
logic	I-General_Concept
unit	I-General_Concept
(	O
ALU	O
)	O
to	O
manipulate	O
its	O
value	O
.	O
</s>
<s>
Typically	O
push	B-Application
and	I-Application
pop	I-Application
are	O
translated	O
into	O
multiple	O
micro-ops	B-General_Concept
,	O
to	O
separately	O
add/subtract	O
the	O
stack	B-Application
pointer	O
,	O
and	O
perform	O
the	O
load/store	O
in	O
memory	O
.	O
</s>
<s>
Newer	O
processors	O
contain	O
a	O
dedicated	O
stack	B-Application
engine	O
to	O
optimize	O
stack	B-Application
operations	O
.	O
</s>
<s>
Pentium	B-Architecture
M	I-Architecture
was	O
the	O
first	O
x86	B-Operating_System
processor	O
to	O
introduce	O
a	O
stack	B-Application
engine	O
.	O
</s>
<s>
In	O
its	O
implementation	O
,	O
the	O
stack	B-Application
pointer	O
is	O
split	O
among	O
two	O
registers	O
:	O
ESPO	O
,	O
which	O
is	O
a	O
32-bit	O
register	O
,	O
and	O
ESPd	O
,	O
an	O
8-bit	O
delta	O
value	O
that	O
is	O
updated	O
directly	O
by	O
stack	B-Application
operations	O
.	O
</s>
<s>
If	O
ESPd	O
is	O
near	O
overflow	O
or	O
the	O
ESP	O
register	O
is	O
referenced	O
from	O
other	O
instructions	O
(	O
when	O
ESPd	O
≠	O
0	O
)	O
,	O
a	O
synchronisation	O
micro-op	B-General_Concept
is	O
inserted	O
that	O
updates	O
the	O
ESPO	O
using	O
the	O
ALU	O
and	O
resets	O
ESPd	O
to	O
0	O
.	O
</s>
<s>
A	O
stack	B-Application
engine	O
similar	O
to	O
Intel	O
's	O
was	O
also	O
adopted	O
in	O
the	O
AMD	B-Device
K8	I-Device
microarchitecture	O
.	O
</s>
<s>
In	O
Bulldozer	O
,	O
the	O
need	O
for	O
synchronization	O
micro-ops	B-General_Concept
was	O
removed	O
,	O
but	O
the	O
internal	O
design	O
of	O
the	O
stack	B-Application
engine	O
is	O
not	O
known	O
.	O
</s>
