LOGBOOK

HELP

← again tap: answer good → ↑ swipe up at the end: next

1 / 8 Part 1 of 2
Other keys: show • Space: good • 1-4: rate • 0: skip • 5: flag

Question

After cmp A, B in AT&T syntax, how do you read the conditional jump?

Answer

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 minus A and sets flags; the following jump is read as B relative to A, with a warning against reading it as A relative to B

* 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:

or press any other key

Question

What is the difference between je/jne and jz/jnz?

Answer

They are the same instruction — je/jz are two names for one opcode (jump if ZF=1), and jne/jnz for another (jump if ZF=0).

Name Alias Meaning Flag checked
je jz Jump if equal / zero ZF = 1
jne jnz Jump if not equal / not zero ZF = 0

Use je/jne after cmp (comparing two values). Use jz/jnz after test or arithmetic (checking if result is zero). The assembler doesn't care — it's purely a readability convention.

Go deeper:

or press any other key