jge
Jump if greater or equal (SF == OF)
Jumps to the target when the last comparison found greater or equal (SF equals OF).
8086 and later
Also written as: jnl
- cmp and the conditional jumpsx86-64 assembly
- call, ret and the System V conventionx86-64 assembly
- The bigger of two numbersx86-64 assembly
- Recursion: factorial and Fibonaccix86-64 assembly
- Changes no flag
- Reads SF OF
Forms
jge shortjgejge near386 and later
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.
The condition reads the current flags, commonly set by cmp or test. Signed comparisons use SF and OF; unsigned comparisons use CF. The condition-code table lists the flag tests and synonymous mnemonics.
Write the target label or address, such as jne retry. NASM calculates a displacement from the end of the jump. The short form reaches −128 through 127 bytes from that point; the longer near form in 64-bit mode uses a signed 32-bit displacement (about ±2 GiB). NASM normally selects the short form when possible. short requires the short range, while strict near keeps the longer form.
Conditional jumps have no register or memory-indirect target form. To conditionally reach an arbitrary 64-bit address, branch around an indirect jmp.
global _start
section .text
_start:
mov rax, 12
cmp rax, 12 ; sets the flags the condition reads
jge taken
mov rbx, 1 ; runs when the condition is false
jmp done
taken:
mov rbx, 2 ; runs when it is true
done:
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall