Processor Status Flags
After the ALU computes a result, the processor doesn't just store it and move on. It also records metadata about what just happened in a special register called the status register (or flags register). Each bit of this register is a flag — a yes/no answer to a question about the last operation.
The essential flags are:
Zero (Z): Was the result exactly zero? If the ALU subtracted two equal numbers, Z=1.
Carry (C): Did an addition overflow past 8 bits? If 200+100 = 300 (which doesn't fit in a byte), C=1.
Negative (N): Is the result negative? In two's complement, this is simply the most significant bit.
Overflow (V): Did a signed operation produce a mathematically incorrect result due to wraparound?
Flags are what make conditional jumps possible. The instruction JZ label doesn't look at data — it looks at the Z flag. If Z=1, the program counter jumps to label. If Z=0, execution continues to the next instruction. This is how if-else and loop constructs are implemented at the hardware level.
Practical example. A comparison instruction CMP A, B is secretly just a subtraction (A - B) where the result is discarded, but the flags are updated. After CMP 5, 5, the Z flag is set to 1 (because 5-5=0). Then JZ equal checks that flag and jumps to the "equal" branch. The processor never "compared" anything — it subtracted, noted the result was zero, and let the conditional jump do the rest.