# `leave`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/leave

**Destroy stack frame**

Category: Stack

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

186 and later

[Intel's reference: LEAVE](https://intel.github.io/SDM/instruction/LEAVE.html)

Used in: [call, ret and the System V convention](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/call-ret-and-the-system-v-convention.md) (x86-64 assembly), [Stack arguments and a stack frame](https://asm-editor.specy.app/learn/courses/x86/examples/subroutine-with-stack-arguments.md) (x86-64 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | not changed |

## Forms

- `leave`

## Description

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.

## Example

```x86
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
```
