LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the jX (conditional jump) instructions?

jX instructions jump to a label only if the condition codes match — they're how if, loops, and comparisons turn into branches in machine code.

After a cmp, three jump families keyed to equality, signed and unsigned flags.

* The same cmp feeds three jump families — equality (ZF), signed (SF/OF), unsigned (CF); picking the wrong one is a real bug. *

A conditional jump reads the flags left by a preceding cmp/test/arithmetic and either jumps or falls through. The suffixes mirror SetX exactly.

Instruction Condition Meaning
jmp always unconditional
je / jne ZF / ~ZF equal / not equal
js / jns SF / ~SF negative / non-negative
jg / jge signed greater / greater-or-equal
jl / jle signed less / less-or-equal
ja / jb unsigned above / below

A typical if (x > y) { … } else { … } compiles to compare-then-branch:

cmpq %rsi, %rdi   # x vs y
jle  .L_else      # if x <= y, skip the "then"
...               # then block
jmp  .L_done
.L_else:
...               # else block
.L_done:

Crucial distinction: signed comparisons use jg/jl (which read SF and OF), unsigned use ja/jb (which read CF). Picking the wrong one is a real bug — the same bytes compare differently depending on signedness.

Go deeper:

From Quiz: REVE1 / The Processor Interface | Updated: Jul 14, 2026