# `jmp`

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

**Jump unconditionally**

Category: Control flow

Jumps unconditionally to the given address.

8086 and later

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

Used in: [cmp and the conditional jumps](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/cmp-and-the-conditional-jumps.md) (x86-64 assembly), [Loops](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/loops.md) (x86-64 assembly), [Arrays, strings and the string instructions](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/arrays-strings-and-the-string-instructions.md) (x86-64 assembly), [Floating point and the x87 stack](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/floating-point-and-the-x87-stack.md) (x86-64 assembly), [SSE2 scalar and packed arithmetic](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/sse-and-packed-arithmetic.md) (x86-64 assembly), [syscall and the Linux x86-64 ABI](https://asm-editor.specy.app/learn/courses/x86/talking-to-the-outside-world/syscall-and-the-linux-abi.md) (x86-64 assembly), [The largest element](https://asm-editor.specy.app/learn/courses/x86/examples/max-of-an-array.md) (x86-64 assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/x86/examples/string-length.md) (x86-64 assembly), [Reverse a string in place](https://asm-editor.specy.app/learn/courses/x86/examples/reverse-a-string.md) (x86-64 assembly), [Even or odd, count the set bits, multiply by shifting](https://asm-editor.specy.app/learn/courses/x86/examples/bit-tricks.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

- `jmp short imm8`
- `jmp imm`
- `jmp near imm32` · 386 and later
- `jmp near r/m64`
- `jmp far mem` (32, 64)
  - `jmp mem32`: 386 and later
  - `jmp mem64`

## Operands

- `imm8`: A branch target, written as a label or address. NASM calculates the displacement from the end of the instruction. The displacement must fit a signed byte, `-128` to `127`.
- `imm`: A branch target, written as a label or address. NASM calculates the displacement from the end of the instruction. NASM selects a short or near encoding according to the target’s reach and any size constraint.
- `imm32`: A branch target, written as a label or address. NASM calculates the displacement from the end of the instruction. In 64-bit mode the encoded displacement is signed 32-bit, `-2147483648` to `2147483647`, even though the target address is 64-bit.
- `r/m64`: A 64-bit general-purpose register or quadword in memory, for example `rax` or `qword [rsi]`.
- `mem`: A memory location addressed with square brackets, for example `[rbx+8]` or `[label]`.

## Description

`jmp target` names a label or target address; NASM calculates a displacement from the end of the instruction. A short jump uses a signed 8-bit displacement (−128 through 127 bytes); the ordinary longer near form in 64-bit mode uses a signed 32-bit displacement (about ±2 GiB), not an absolute 64-bit address.

NASM normally chooses a short encoding when the target fits. `short` requires that range; `strict near` prevents shortening to the 8-bit form.

`jmp rax` takes the full target address from the register, and `jmp [pointer]` reads an 8-byte target address from memory. These indirect near jumps have no relative displacement limit.

A far jump also changes `cs`. A far memory pointer contains the offset first, then a 16-bit selector: 16-, 32- and 64-bit offsets occupy 4, 6 and 10 bytes in total. Immediate `segment:offset` jumps are unavailable in 64-bit mode. Far transfers require valid operating-system segment descriptors and are not ordinary branches in a Linux program.

## Example

```x86
global _start

section .text
_start:
        mov rax, 1
        jmp skip
        mov rax, 99         ; never runs
skip:
        mov rbx, rax

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