Skip to content

Instructions

x86-64

Conditional Jumps (Jcc)

The Jcc family transfers control based on EFLAGS bits set by prior CMP, TEST, or arithmetic instructions — the source of all if/loop control flow.

The Jcc (Jump if Condition) family reads one or more EFLAGS bits and jumps if the condition is satisfied. They are the direct machine-code representation of if, while, for, and similar constructs.

Common mnemonics

MnemonicAliasConditionFlags tested
jejzEqual / ZeroZF=1
jnejnzNot equal / Not zeroZF=0
jgjnleGreater (signed)ZF=0 and SF=OF
jgejnlGreater or equal (signed)SF=OF
jljngeLess (signed)SF≠OF
jlejngLess or equal (signed)ZF=1 or SF≠OF
jajnbeAbove (unsigned)CF=0 and ZF=0
jbjc, jnaeBelow (unsigned)CF=1
jaejnb, jncAbove or equal (unsigned)CF=0
jbejnaBelow or equal (unsigned)CF=1 or ZF=1
js—Sign (negative)SF=1
jo—OverflowOF=1
jpjpeParity evenPF=1

Usage pattern

asm
cmp rax, rbx      ; sets ZF/CF/SF/OF based on rax - rbx
je  equal_label   ; jump if rax == rbx
jg  greater_label ; jump if rax > rbx (signed)
ja  above_label   ; jump if rax > rbx (unsigned)

Signed vs unsigned: the key distinction

jg/jl use SF and OF (signed comparison); ja/jb use CF (unsigned). When reversing pointer arithmetic or security checks, picking the wrong interpretation leads to incorrect decompiler output.

Reverse-engineering notes

  • Decompilers map je/jne → ==/!=, jl/jg → </> for signed integers, and jb/ja → </> for unsigned (or pointer comparisons).
  • A test rax, rax; je null_check pattern means "if rax == 0" — the test just sets ZF without a cmp.
  • Reversed conditions (negated jumps) are common in optimised code to avoid an extra jmp; jne loop_top at the bottom of a loop is equivalent to a do { } while (x != 0) in C.
  • Obfuscated binaries occasionally use opaque predicates — a Jcc whose condition is always true/false — to confuse disassemblers.

Try it — Virtual CPU

open full playground →
program— ▸ is the next instruction
  1. xor eax, eax
  2. mov ecx, 1
  3. loop_start:
  4. add eax, ecx
  5. inc ecx
  6. cmp ecx, 6
  7. jl loop_start
step 0
Loading emulator…