# `pop`

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

**Pop a value from the stack**

Category: Stack

Pops a 64-bit value using rsp by default, or a 16-bit value when a word operand is selected.

8086 and later

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

Used in: [The stack, push and pop](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/the-stack-push-and-pop.md) (x86-64 assembly), [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), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/x86/examples/factorial-and-fibonacci.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

- `pop reg` (16, 64)
  - `pop reg16`
  - `pop reg64`
- `pop r/m` (16, 64)
  - `pop r/m16`
  - `pop r/m64`
- `pop fs` · 386 and later
- `pop gs` · 386 and later

## Operands

- `reg`: A general-purpose register matching the operation’s size, for example `al`, `ax`, `eax` or `rax`.
- `r/m`: A general-purpose register or memory location matching the operation’s size, for example `rax` or `qword [rbp-8]`.

## Description

A 16-bit operand pops two bytes instead: `pop ax` adds 2. There is no 32-bit general-purpose pop in 64-bit mode, so `pop eax` is invalid. Popping into `rsp` replaces it with the loaded value.

An address-size prefix changes an explicit memory destination's addressing, not the stack pointer used to read the value. For a memory destination based on `rsp`, the destination address is calculated after the stack increment. Only `fs` and `gs` segment pops are available in 64-bit mode; loading them is subject to segment-selector checks.

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        push rax
        mov rax, 99
        pop rax             ; 12 again

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