LOGBOOK

HELP

Quiz Entry - updated: 2026.07.06

What is the leave instruction?

leave tears down a frame-pointer stack frame in one instruction: mov %rbp, %rsp then pop %rbp.

leave performs mov %rbp,%rsp then pop %rbp: it drops the local variables and restores the caller's frame pointer before ret

* leave is a one-instruction frame teardown — mov %rbp,%rsp (reclaim locals) then pop %rbp — usually right before ret. *

# These two instructions:
mov %rbp, %rsp
pop %rbp

# Are equivalent to:
leave

When you see it: In functions compiled with a frame pointer (-fno-omit-frame-pointer), the prologue sets up %rbp and the epilogue uses leave:

func:
    push %rbp
    mov  %rsp, %rbp
    sub  $0x20, %rsp
    ...
    leave
    ret

leave restores %rsp to where it was before the local variable allocation, then restores the old %rbp.

Go deeper:

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 06, 2026