80386 Programmer's Reference Manual -- Opcode LEAVE

LEAVE -- High Level Procedure Exit

OpcodeInstructionClocks DescriptionExample
C9leave 4 Set SP to BP, then pop BPleave
C9leave 4 Set ESP to EBP, then pop EBPleave


IF StackAddrSize = 16
   SP := BP;
ELSE (* StackAddrSize = 32 *)
   ESP := EBP;
IF OperandSize = 16
   BP := Pop();
ELSE (* OperandSize = 32 *)
   EBP := Pop();


LEAVE reverses the actions of the ENTER 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 RET instruction removes any arguments pushed onto the stack of the exiting procedure.

Flags Affected


Protected Mode Exceptions

#SS(0) if BP does not point to a location within the limits of the current stack segment

Real Address Mode Exceptions

Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH

Virtual 8086 Mode Exceptions

Same exceptions as in Real Address Mode

[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]