Files
oldlinux-files/Ref-docs/manual Intel386/I386Manual/LEAVE.HTM
2024-02-19 00:21:47 -05:00

60 lines
2.4 KiB
HTML

<html><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>80386 Programmer's Reference Manual -- Opcode LEAVE</title>
</head>
<body>
<b>up:</b> <a href="C17.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C17.HTM">Chapter 17 -- 80386 Instruction Set</a><br>
<b>prev:</b><a href="LEA.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/LEA.HTM"> LEA Load Effective Address</a><br>
<b>next:</b><a href="LGDT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/LGDT.HTM"> LGDT/LIDT Load Global/Interrupt Descriptor Table Register</a>
<p>
<hr>
<p>
<h1>LEAVE -- High Level Procedure Exit</h1>
<pre>
Opcode Instruction Clocks Description
C9 LEAVE 4 Set SP to BP, then pop BP
C9 LEAVE 4 Set ESP to EBP, then pop EBP
</pre>
<h2>Operation</h2>
<pre>
IF StackAddrSize = 16
THEN
SP := BP;
ELSE (* StackAddrSize = 32 *)
ESP := EBP;
FI;
IF OperandSize = 16
THEN
BP := Pop();
ELSE (* OperandSize = 32 *)
EBP := Pop();
FI;
</pre>
<h2>Description</h2>
LEAVE reverses the actions of the <a href="ENTER.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/ENTER.HTM">ENTER</a> instruction. By copying the frame pointer to the stack pointer, LEAVE releases the stack space used by a procedure for its local variables. The old frame pointer is popped into BP or EBP, restoring the caller's frame. A subsequent <a href="RET.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/RET.HTM">RET</a> instruction removes any arguments pushed onto the stack of the exiting procedure.
<h2>Flags Affected</h2>
None
<h2>Protected Mode Exceptions</h2>
#SS(0) if BP does not point to a location within the limits of the current stack segment
<h2>Real Address Mode Exceptions</h2>
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH
<h2>Virtual 8086 Mode Exceptions</h2>
Same exceptions as in Real Address Mode
<p>
<hr>
<p><b>up:</b> <a href="C17.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C17.HTM">Chapter 17 -- 80386 Instruction Set</a><br>
<b>prev:</b><a href="LEA.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/LEA.HTM"> LEA Load Effective Address</a><br>
<b>next:</b><a href="LGDT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/LGDT.HTM"> LGDT/LIDT Load Global/Interrupt Descriptor Table Register</a>
</body>