xolatilization/xanual/leave.md

1.3 KiB
Executable File

LEAVE — High Level Procedure Exit

Description

Releases the stack frame set up by an earlier ENTER instruction. The LEAVE instruction copies the frame pointer (in the EBP register) into the stack pointer register (ESP), which releases the stack space allocated to the stack frame. The old frame pointer (the frame pointer for the calling procedure that was saved by the ENTER instruction) is then popped from the stack into the EBP register, restoring the calling procedure's stack frame.

Instruction

Opcode Assembly Op/En Modern Mode Legacy Mode Description
C9 LEAVE NP Valid Valid Set SP to BP, then pop BP.
C9 LEAVE NP N.E. Valid Set ESP to EBP, then pop EBP.
C9 LEAVE NP Valid N.E. Set RSP to RBP, then pop RBP.

Information

A RET instruction is commonly executed following a LEAVE instruction to return program control to the calling procedure.