a conditional branch
A program is not just a straight list of steps run top to bottom; it makes decisions. If the password matches, log in; otherwise, refuse. At the machine level this fork in the road is a conditional branch: an instruction that tests something and then either jumps to a different place in the code or just falls through to the next line, depending on the result. It is the hardware's way of asking a yes/no question and going down one of two paths.
A branch works on the program counter, the register that holds the address of the next instruction. Normally the program counter just advances to the following instruction. A conditional branch compares two values (or checks a flag) and, if the condition holds, replaces the program counter with the address of a labeled target instead. In RISC-V, beq a0, a1, label means branch if a0 equals a1: if they are equal, execution jumps to label; if not, it continues straight on. There are variants for not-equal (bne), less-than (blt), greater-or-equal (bge), and so on. This is the single building block from which IF/ELSE and loops are made.
Conditional branches matter enormously for performance, not just correctness. A processor running ahead at full speed does not know which way a branch will go until it is evaluated, so it guesses (branch prediction) and quietly does the work for the predicted path. A wrong guess wastes that work. That is why deeply nested, unpredictable branching can be slow, and why compilers and programmers sometimes restructure code to make branches more predictable or to avoid them entirely.
Translating if (a == b) x = 1; else x = 2; by hand: beq a0, a1, equal # if a0 == a1 jump to equal li t0, 2 # else branch: x = 2 j done equal: li t0, 1 # then branch: x = 1 done: The beq picks which path runs; j (jump) skips past the else.
IF/ELSE becomes a conditional branch plus an unconditional jump and a couple of labels.
A common bug when hand-translating: forgetting the unconditional jump over the else block, so the then-path falls through and runs the else code too.