# `enterq`

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

**Create 64-bit stack frame**

Category: Stack

Creates a 64-bit stack frame for a procedure call: pushes rbp, sets rbp to rsp, and reserves the local bytes.

x86-64 and later

[Intel's reference: ENTER](https://intel.github.io/SDM/instruction/ENTER.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

- `enterq imm16, imm8`
- `enterq imm16`

## Operands

- `imm16`: A 16-bit immediate, `-32768` to `65535`.
- `imm8`: An 8-bit immediate, `-128` to `255`. Instructions that sign-extend it to a wider operand interpret the byte as `-128` to `127`; shift counts do not use this sign extension.

## Description

The first immediate is an unsigned 16-bit byte count for local storage; the second is a nesting level whose low five bits are used (0–31). NASM also accepts a single operand, with nesting level zero.

In 64-bit code, `enter 32, 0` has the frame-building effect of:

```x86
push rbp
mov rbp, rsp
sub rsp, 32
```

Unlike the `sub` in that sequence, `enter` leaves flags unchanged. The saved frame pointer is at `[rbp]`, and local storage lies below `rbp`. Nonzero nesting levels also copy enclosing frame pointers in 8-byte slots and push the new frame pointer. `enterq` explicitly selects this 64-bit frame size; `leave` can dismantle the frame.

## Example

```x86
global _start

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

        enterq 5, 5

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