<s>
In	O
assembly	B-Language
language	I-Language
programming	B-General_Concept
,	O
the	O
function	B-Language
prologue	I-Language
is	O
a	O
few	O
lines	O
of	O
code	O
at	O
the	O
beginning	O
of	O
a	O
function	O
,	O
which	O
prepare	O
the	O
stack	B-General_Concept
and	O
registers	B-General_Concept
for	O
use	O
within	O
the	O
function	O
.	O
</s>
<s>
Similarly	O
,	O
the	O
function	B-Language
epilogue	I-Language
appears	O
at	O
the	O
end	O
of	O
the	O
function	O
,	O
and	O
restores	O
the	O
stack	B-General_Concept
and	O
registers	B-General_Concept
to	O
the	O
state	O
they	O
were	O
in	O
before	O
the	O
function	O
was	O
called	O
.	O
</s>
<s>
The	O
prologue	O
and	O
epilogue	O
are	O
not	O
a	O
part	O
of	O
the	O
assembly	B-Language
language	I-Language
itself	O
;	O
they	O
represent	O
a	O
convention	O
used	O
by	O
assembly	B-Language
language	I-Language
programmers	B-Application
,	O
and	O
compilers	B-Language
of	O
many	O
higher-level	O
languages	O
.	O
</s>
<s>
Function	B-Language
prologue	I-Language
and	I-Language
epilogue	I-Language
also	O
sometimes	O
contain	O
code	O
for	O
buffer	B-Error_Name
overflow	I-Error_Name
protection	I-Error_Name
.	O
</s>
<s>
A	O
function	B-Language
prologue	I-Language
typically	O
does	O
the	O
following	O
actions	O
if	O
the	O
architecture	O
has	O
a	O
base	O
pointer	O
(	O
also	O
known	O
as	O
frame	O
pointer	O
)	O
and	O
a	O
stack	B-General_Concept
pointer	O
:	O
</s>
<s>
Pushes	O
current	O
base	O
pointer	O
onto	O
the	O
stack	B-General_Concept
,	O
so	O
it	O
can	O
be	O
restored	O
later	O
.	O
</s>
<s>
Value	O
of	O
base	O
pointer	O
is	O
set	O
to	O
the	O
address	O
of	O
stack	B-General_Concept
pointer	O
(	O
which	O
is	O
pointed	O
to	O
the	O
top	O
of	O
the	O
stack	B-General_Concept
)	O
so	O
that	O
the	O
base	O
pointer	O
will	O
point	O
to	O
the	O
top	O
of	O
the	O
stack	B-General_Concept
.	O
</s>
<s>
Moves	O
the	O
stack	B-General_Concept
pointer	O
further	O
by	O
decreasing	O
or	O
increasing	O
its	O
value	O
,	O
depending	O
on	O
whether	O
the	O
stack	B-General_Concept
grows	O
down	O
or	O
up	O
.	O
</s>
<s>
On	O
x86	B-Operating_System
,	O
the	O
stack	B-General_Concept
pointer	O
is	O
decreased	O
to	O
make	O
room	O
for	O
the	O
function	O
's	O
local	O
variables	O
.	O
</s>
<s>
Several	O
possible	O
prologues	O
can	O
be	O
written	O
,	O
resulting	O
in	O
slightly	O
different	O
stack	B-General_Concept
configuration	O
.	O
</s>
<s>
These	O
differences	O
are	O
acceptable	O
,	O
as	O
long	O
as	O
the	O
programmer	B-Application
or	O
compiler	B-Language
uses	O
the	O
stack	B-General_Concept
in	O
the	O
correct	O
way	O
inside	O
the	O
function	O
.	O
</s>
<s>
The	O
N	O
immediate	O
value	O
is	O
the	O
number	O
of	O
bytes	O
reserved	O
on	O
the	O
stack	B-General_Concept
for	O
local	O
use	O
.	O
</s>
<s>
These	O
prologues	O
push	O
several	O
base/frame	O
pointers	O
to	O
allow	O
for	O
nested	O
functions	O
,	O
as	O
required	O
by	O
languages	O
such	O
as	O
Pascal	B-Application
.	O
</s>
<s>
Function	B-Language
epilogue	I-Language
reverses	O
the	O
actions	O
of	O
the	O
function	B-Language
prologue	I-Language
and	O
returns	O
control	O
to	O
the	O
calling	O
function	O
.	O
</s>
<s>
Drop	O
the	O
stack	B-General_Concept
pointer	O
to	O
the	O
current	O
base	O
pointer	O
,	O
so	O
room	O
reserved	O
in	O
the	O
prologue	O
for	O
local	O
variables	O
is	O
freed	O
.	O
</s>
<s>
Pops	O
the	O
base	O
pointer	O
off	O
the	O
stack	B-General_Concept
,	O
so	O
it	O
is	O
restored	O
to	O
its	O
value	O
before	O
the	O
prologue	O
.	O
</s>
<s>
Returns	O
to	O
the	O
calling	O
function	O
,	O
by	O
popping	O
the	O
previous	O
frame	O
's	O
program	O
counter	O
off	O
the	O
stack	B-General_Concept
and	O
jumping	O
to	O
it	O
.	O
</s>
<s>
Under	O
certain	O
calling	O
conventions	O
it	O
is	O
the	O
callee	O
's	O
responsibility	O
to	O
clean	O
the	O
arguments	O
off	O
the	O
stack	B-General_Concept
,	O
so	O
the	O
epilogue	O
can	O
also	O
include	O
the	O
step	O
of	O
moving	O
the	O
stack	B-General_Concept
pointer	O
down	O
or	O
up	O
.	O
</s>
<s>
For	O
example	O
,	O
these	O
three	O
steps	O
may	O
be	O
accomplished	O
in	O
32-bit	O
x86	B-Language
assembly	I-Language
language	I-Language
by	O
the	O
following	O
instructions	O
:	O
</s>
<s>
Like	O
the	O
prologue	O
,	O
the	O
x86	B-Operating_System
processor	O
contains	O
a	O
built-in	O
instruction	O
which	O
performs	O
part	O
of	O
the	O
epilogue	O
.	O
</s>
<s>
Therefore	O
,	O
programmers	B-Application
or	O
compilers	B-Language
often	O
use	O
the	O
combination	O
of	O
leave	O
and	O
ret	O
to	O
exit	O
the	O
function	O
at	O
any	O
point	O
.	O
</s>
<s>
(	O
For	O
example	O
,	O
a	O
C	B-Language
compiler	B-Language
would	O
substitute	O
a	O
return	O
statement	O
with	O
a	O
leave/ret	O
sequence	O
)	O
.	O
</s>
