LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

How do the setX, jX, and cmovX instruction families relate to one another?

They all read the same condition flags but act on them differently: setX writes a 0/1 byte, jX jumps, and cmovX conditionally copies a register.

cmp and test set the condition flags, which are then read by three consumers sharing the same condition suffixes: setX, jX, and cmovX.

* cmp/test set the condition flags; setX, jX and cmovX all consume the same flags using identical condition suffixes. *

After a cmp or test leaves its verdict in the flags, you have three ways to consume it — and they share the same condition suffixes (e, ne, l, ge, a, b, …):

Family Example What it does
setX setl %al Sets a single byte to 1 if the condition holds, else 0 (other bytes untouched)
jX jl .L2 Branches to a label if the condition holds
cmovX cmovl %rcx, %rax Copies source→dest only if the condition holds, with no branch
cmp %rsi, %rdi
setl %al           # al = (rdi < rsi) ? 1 : 0   -> implements a boolean result

Why cmov matters: It computes a conditional result without a jump, so there's no branch for the CPU to mispredict. Compilers use it for cheap ?: ternaries and small ifs — turning a branch into straight-line code. That's the assembly-level realization of the C ternary operator.

Go deeper:

From Quiz: REVE1 / Translation of C to Assembly | Updated: Jul 14, 2026