* better
[mascara-docs.git] / hw / i386.reference / LEAVE.htm
blobd76e3a4cbd4731002c5b77f6515cae0c34d75548
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode LEAVE</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c17.htm">
8 Chapter 17 -- 80386 Instruction Set</A><BR>
9 <B>prev:</B><A HREF="LEA.htm"> LEA Load Effective Address</A><BR>
10 <B>next:</B><A HREF="LGDT.htm"> LGDT/LIDT Load Global/Interrupt Descriptor Table Register</A>
11 <P>
12 <HR>
13 <P>
14 <H1>LEAVE -- High Level Procedure Exit</H1>
16 <PRE>
17 Opcode Instruction Clocks Description
19 C9 LEAVE 4 Set SP to BP, then pop BP
20 C9 LEAVE 4 Set ESP to EBP, then pop EBP
21 </PRE>
23 <H2>Operation</H2>
25 <PRE>
26 IF StackAddrSize = 16
27 THEN
28 SP := BP;
29 ELSE (* StackAddrSize = 32 *)
30 ESP := EBP;
31 FI;
32 IF OperandSize = 16
33 THEN
34 BP := Pop();
35 ELSE (* OperandSize = 32 *)
36 EBP := Pop();
37 FI;
38 </PRE>
40 <H2>Description</H2>
42 LEAVE reverses the actions of the
43 <A HREF="ENTER.htm">ENTER</A> instruction. By copying the
44 frame pointer to the stack pointer, LEAVE releases the stack space used
45 by a procedure for its local variables. The old frame pointer is popped
46 into BP or EBP, restoring the caller's frame. A subsequent
47 <A HREF="RET.htm">RET</A>
48 instruction removes any arguments pushed onto the stack of the exiting
49 procedure.
51 <H2>Flags Affected</H2>
53 None
55 <H2>Protected Mode Exceptions</H2>
57 #SS(0) if BP does not point to a location within the limits of the current
58 stack segment
60 <H2>Real Address Mode Exceptions</H2>
62 Interrupt 13 if any part of the operand would lie outside of the effective
63 address space from 0 to 0FFFFH
65 <H2>Virtual 8086 Mode Exceptions</H2>
67 Same exceptions as in Real Address Mode
70 <P>
71 <HR>
72 <P>
73 <B>up:</B> <A HREF="c17.htm">
74 Chapter 17 -- 80386 Instruction Set</A><BR>
75 <B>prev:</B><A HREF="LEA.htm"> LEA Load Effective Address</A><BR>
76 <B>next:</B><A HREF="LGDT.htm"> LGDT/LIDT Load Global/Interrupt Descriptor Table Register</A>
77 </BODY>