# `leavew`

[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/leavew

**Destroy 16-bit stack frame**

Category: Stack

Dismantles a frame using a 16-bit saved frame pointer.

186 and later

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

## 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

- `leavew`

## Description

In 64-bit mode it sets `rsp` from `rbp`, then pops two bytes into `bp`, advancing `rsp` by 2. It leaves flags unchanged. This is distinct from the normal 64-bit `leave` / `leaveq` form.

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        leavew

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