LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the difference between an unconditional branch and a conditional branch, and how is a branch implemented at the hardware level?

An unconditional branch always jumps; a conditional branch jumps only when a tested condition holds.

A branch sets the program counter; an unconditional jmp always sets PC to the target while a conditional jl branches only if its condition holds, otherwise falling through.

* Both branch kinds set PC, but a conditional branch falls through when the tested condition is false. *

Assembly has no if or goto keyword — control flow exists only as branch instructions that change where the processor reads its next instruction. Mechanically, a branch just sets the program counter (PC) to the target's address: PC = &label. The CPU then fetches from there instead of the next sequential instruction.

Type x86 syntax Behavior
Unconditional jmp .L7 Always continues at .L7
Conditional jl .L2 Continues at .L2 only if the "less-than" condition is true, else falls through
    subl %eax, %edx
    movl %edx, %eax
    jmp  .L7          # always taken
    ...
.L7:
    ...

A high-level goto label maps directly onto jmp label. Every loop, if, and switch you write in C is ultimately built out of these two primitives.

Go deeper:

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