# `jp`

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

**Jump**

Category: Control flow

Jumps to a 16-bit address, or to the address held in HL, IX or IY, either always or only when a flag condition is met.

Used in: [jp, jr and the conditions](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/jp-jr-and-the-conditions.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), [The screen, keyboard and mouse through ports](https://asm-editor.specy.app/learn/courses/z80/talking-to-the-outside-world/screen-keyboard-and-mouse.md) (Z80 assembly), [The largest element](https://asm-editor.specy.app/learn/courses/z80/examples/max-of-an-array.md) (Z80 assembly), [A subroutine with its arguments in registers](https://asm-editor.specy.app/learn/courses/z80/examples/subroutine-with-register-arguments.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), [A jump table](https://asm-editor.specy.app/learn/courses/z80/examples/jump-table.md) (Z80 assembly), [A bouncing ball](https://asm-editor.specy.app/learn/courses/z80/examples/bouncing-ball.md) (Z80 assembly), [Move a square with the keyboard](https://asm-editor.specy.app/learn/courses/z80/examples/keyboard-control.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

- `jp nnnn` · 3 bytes · 10 cycles · `nnnn` is copied to PC.

- `jp cc, nnnn` · 3 bytes · 10 cycles · If the condition `cc` is true, `nnnn` is copied to PC.
  - `jp nz, nnnn`
  - `jp z, nnnn`
  - `jp nc, nnnn`
  - `jp c, nnnn`
  - `jp po, nnnn`
  - `jp pe, nnnn`
  - `jp p, nnnn`
  - `jp m, nnnn`

- `jp (hl)` · 1 byte · 4 cycles · Loads the value of HL into PC.

- `jp (ix)` · 2 bytes · 8 cycles · Loads the value of IX into PC.
  - `jp (ix)`
  - `jp (iy)`

## Pseudo-instructions

Other spellings the assembler accepts; each form shows the instruction it becomes.

- `jp hl` · 1 byte · 4 cycles · Loads the value of HL into PC.
  - `jp hl` → `jp (hl)`

- `jp cc, nnnn` · 3 bytes · 10 cycles · cc: nv v · If the condition `cc` is true, `nnnn` is copied to PC.
  - `jp nv, nnnn` → `jp po, nnnn`
  - `jp v, nnnn` → `jp pe, nnnn`

- `jp ix` · 2 bytes · 8 cycles · Loads the value of IX into PC.
  - `jp ix` → `jp (ix)`
  - `jp iy` → `jp (iy)`

## Operands

- [`nnnn`](https://asm-editor.specy.app/documentation/z80/registers/operand-nnnn.md): A 16-bit value or address, `0` to `65535`, written as a number or label. `(nnnn)` accesses memory at that address.
- [`cc`](https://asm-editor.specy.app/documentation/z80/registers/operand-cc.md): A flag condition: `nz` (zero flag clear, `Z = 0`), `z` (zero flag set, `Z = 1`), `nc` (carry flag clear, `C = 0`), `c` (carry flag set, `C = 1`), `po` (parity/overflow flag clear, `P/V = 0`), `pe` (parity/overflow flag set, `P/V = 1`), `p` (sign flag clear, `S = 0`), `m` (sign flag set, `S = 1`), `nv` (alias for `po`, `P/V = 0`) or `v` (alias for `pe`, `P/V = 1`). Here `c` tests the carry flag; it does not name the `c` register.
- [`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
        jp nz, target
target: halt
```
