# `pop`

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

Web page: https://asm-editor.specy.app/documentation/z80/instruction/pop

**Pop from stack**

Category: Stack

Loads BC, DE, HL, AF, IX or IY from the stack, incrementing SP once for each byte.

Used in: [The stack, push and pop](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/the-stack-push-and-pop.md) (Z80 assembly), [call, ret and passing values](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/call-ret-and-passing-values.md) (Z80 assembly), [Interrupts: im, ei, di and halt](https://asm-editor.specy.app/learn/courses/z80/talking-to-the-outside-world/interrupts-im-ei-di-and-halt.md) (Z80 assembly), [Stack arguments and a stack frame](https://asm-editor.specy.app/learn/courses/z80/examples/subroutine-with-stack-arguments.md) (Z80 assembly), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/z80/examples/factorial-and-fibonacci.md) (Z80 assembly), [Binary search](https://asm-editor.specy.app/learn/courses/z80/examples/binary-search.md) (Z80 assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/z80/examples/two-dimensional-array.md) (Z80 assembly), [Read two numbers and print their sum](https://asm-editor.specy.app/learn/courses/z80/examples/sum-of-two-numbers.md) (Z80 assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/z80/examples/flappy-asm.md) (Z80 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| S | not changed |
| Z | not changed |
| H | not changed |
| P/V | not changed |
| N | not changed |
| C | not changed |

## Forms

- `pop rr` · 1 byte · 10 cycles · rr: bc de hl · Loads the value pointed to by SP into the low byte of `rr` and increments SP, then loads the value pointed to by SP into the high byte of `rr` and increments SP again.
  - `pop bc`
  - `pop de`
  - `pop hl`

- `pop af` · 1 byte · 10 cycles · Flags: S: loaded from the stack, Z: loaded from the stack, H: loaded from the stack, P/V: loaded from the stack, N: loaded from the stack, C: loaded from the stack · Loads the value pointed to by SP into F and increments SP, then loads the value pointed to by SP into A and increments SP again.

- `pop ix` · 2 bytes · 14 cycles · Loads the value pointed to by SP into IXL and increments SP, then loads the value pointed to by SP into IXH and increments SP again.
  - `pop ix`
  - `pop iy`

## Operands

- `rr`: A register pair: `bc`, `de` or `hl`.
- [`ix`](https://asm-editor.specy.app/documentation/z80/registers/register-ix.md): The `ix` index register. You can also use `iy`, with the same instruction size and timing.

## Example

```z80
        .org 0x8000
        ld bc, 0x1234
        push bc
        pop bc
        halt
```
