Quiz Entry - updated: 2026.07.06
After cmp A, B in AT&T syntax, how do you read the conditional jump?
Read it as "jump if B (condition) A" — cmp A, B computes B - A, so the condition is about the second operand relative to the first.
* cmp A, B computes B - A, so the conditional jump reads as B relative to A (not A relative to B). *
cmp $5, %eax
jl label
Reads as: "jump if %eax < 5"
cmp %ebx, %eax
jge label
Reads as: "jump if %eax >= %ebx"
Why? cmp A, B computes B - A and sets flags. The conditional jump then tests those flags as if asking about B relative to A.
Common mistake: Reading it as "A < B" because A comes first — but AT&T source-destination order means A is subtracted FROM B.
Go deeper:
CMP instruction reference — confirms cmp subtracts the second operand from the first and sets the same flags as SUB.
Jcc conditional-jump reference — shows exactly which flags each jl/jge/etc tests after the compare.