LOGBOOK

HELP

Quiz Entry - updated: 2026.07.06

What do the setCC instructions (e.g. sete, setg, setl) do, and how do they differ from jCC?

setCC dst writes 1 or 0 into a single byte based on the condition flags, instead of jumping — it's how the compiler turns a comparison into a boolean value.

jCC (jump-if-condition) and setCC (set-if-condition) read the same flags from the same cmp/test; they just consume them differently. A jump changes control flow; a set produces a 0/1 result you can store or compute with.

cmp   %esi, %edi
setl  %al          # %al = 1 if %edi < %esi (signed), else 0
movzbl %al, %eax   # zero-extend the byte to a full int

Why this pattern matters: It's exactly how C code like int b = (x < y); compiles. There's no branch at all — the result is just a byte. You'll almost always see setCC followed by a movzbl (zero-extend), because setCC only writes the low 8-bit register (%al, %dl, ...) and the upper bits must be cleared to make a clean int.

Same condition letters as jumps: sete/setne (zero), setl/setg (signed), setb/seta (unsigned), sets/setns (sign). If you can read a jCC, you can read the matching setCC — only the action differs.

Go deeper:

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 06, 2026