leave

Destroy stack frame

Destroys the stack frame made by enter by setting rsp to rbp and popping the saved rbp.

186 and later

Intel's reference: LEAVE

CFPFAFZFSFDFOF –––––––
  • Changes no flag

Forms

  • leave

It has the effect of mov rsp, rbp followed by pop rbp and leaves flags unchanged. It can match an enter frame or the usual explicit frame setup. leaveq explicitly selects the 64-bit form.

global _start

section .text
_start:
        enter 16, 0
        mov qword [rbp - 8], 12
        leave               ; undoes the frame enter made

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall