LEAVE is an analogue of ENTER . The ENTER instruction sets the stack stack by first pushing EBP the stack and then copying the ESP to EBP , so LEAVE must do the opposite, i.e. copy EBP to ESP and then restore the old EBP from the stack.
See “PROCEDURAL CALLS FOR BLOCK STRUCTURAL LANGUAGES” in Intel Developer's Guide for Developers Volume 1, if you want to learn more about how ENTER and LEAVE .
source share