jmp
Jump unconditionally
Jumps unconditionally to the given address.
8086 and later
- cmp and the conditional jumpsx86-64 assembly
- Loopsx86-64 assembly
- Arrays, strings and the string instructionsx86-64 assembly
- Floating point and the x87 stackx86-64 assembly
- SSE2 scalar and packed arithmeticx86-64 assembly
- syscall and the Linux x86-64 ABIx86-64 assembly
- The largest elementx86-64 assembly
- Length of a stringx86-64 assembly
- Reverse a string in placex86-64 assembly
- Even or odd, count the set bits, multiply by shiftingx86-64 assembly
- Changes no flag
Forms
jmp shortjmpjmp near386 and laterjmp near
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,
-128to127. 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,
-2147483648to2147483647, even though the target address is 64-bit. r/m64- A 64-bit general-purpose register or quadword in memory, for example
raxorqword [rsi]. mem- A memory location addressed with square brackets, for example
[rbx+8]or[label].
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.
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