4-24
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
4.5.2.LEAVE Instruction
The LEAVE instruction, which does not have any operands, reverses the action of the previous
ENTER instruction. The LEAVE instruction copies the contents of the EBP register into the ESP
register to release all stack space allocated to the procedure. Then it restores the old value of the
EBP register from the stack. This simultaneously restores the ESP register to its original value.
A subsequent RET instruction then can remove any arguments and the return address pushed on
the stack by the calling program for use by the procedure.
Figure 4-10. Stack Frame after Entering Procedure C
EBP
Display
Old EBP
ESP
Mains EBP
Dynamic
Storage
Procedure As EBP
Mains EBP
Mains EBP
Procedure As EBP
Procedure Bs EBP
Mains EBP
Procedure As EBP
Procedure Bs EBP
Procedure Cs EBP
Mains EBP
Procedure As EBP