Status Registers: Zero, Carry, and Overflow Flags

A status register, often called a flags register or condition code register, is a dedicated hardware register in a central processing unit (CPU) that records the outcome of arithmetic, logical, and comparison operations. This article explores the architecture of the status register and details how three critical flag bits—the Zero Flag (Z), the Carry Flag (C), and the Overflow Flag (V)—interpret and report state changes in binary arithmetic.

What Is a Status Register?

A status register consists of individual, independent 1-bit memory cells known as flags. Unlike general-purpose registers that hold data values or memory addresses, the status register holds metadata about the most recently executed instruction in the Arithmetic Logic Unit (ALU).

Each bit within the register is automatically updated by the CPU hardware based on predefined criteria. The processor then evaluates these bits to make decisions, such as executing conditional branch instructions (JUMP IF ZERO, BRANCH IF GREATER THAN), enabling loops, and handling multi-word arithmetic.

The Zero Flag (Z)

The Zero Flag indicates whether the result of the previous operation evaluated to zero.

The Carry Flag (C)

The Carry Flag monitors carry-out and borrow operations during unsigned binary arithmetic. It tracks whether an operation has exceeded the fixed bit-width of the target register.

The Overflow Flag (V or OF)

The Overflow Flag monitors boundary violations during signed binary arithmetic, which is represented using Two’s Complement notation. It alerts the system that an operation has produced a result with an incorrect mathematical sign because the value fell outside the representable signed range.

Summary of Differences

While both Carry and Overflow signal that a result does not fit within a fixed bit-width, they serve distinct number representations: