Skip to content
BetterDL

Carry flag (C)

Also called: C flag, borrow flag

The status flag C, which holds the adder's carry-out. After an addition C = 1 means unsigned overflow; after a subtraction here, C = 1 means no borrow.

The carry flag C stores the carry out Cₙ of the ALU's adder. It's the flag for unsigned arithmetic.

  • After ADD: C = 1 means the unsigned sum didn't fit in n bits (unsigned overflow). The result shows the true sum minus 2ⁿ.
  • After SUB, computed as A + + 1: C = 1 means no borrow, so A ≥ B. C = 0 means a borrow: A < B as unsigned numbers, and the result has wrapped around.

That makes C the unsigned comparison flag. After A − B: C = 0 means A < B; C = 1 with Z = 0 means A > B; Z = 1 means they're equal.

Two conventions exist. This course, like ARM processors, keeps the raw carry-out, so C = 1 means no borrow after SUB. x86 processors invert it on subtraction and treat it as a borrow, so there C = 1 means a borrow happened. Check which convention a question uses.

C says nothing about signed results. For twos complement numbers, use the overflow flag V. A carry-out of 1 is completely normal when adding two negative numbers, for example.

Worked example

Example

C after an addition and two subtractions

All in 4 bits.

  1. 1.

    ADD 1001 + 1000 = 1 0001: C = 1. Unsigned 9 + 8 = 17 didn't fit.

  2. 2.

    SUB 0101 − 0011: 0101 + 1100 + 1 = 18 = 1 0010. C = 1, no borrow: 5 ≥ 3, and the result 2 is right.

  3. 3.

    SUB 0011 − 0101: 0011 + 1010 + 1 = 14 = 1110. C = 0, a borrow: 3 < 5.

Common mistakes

  • Using C to detect signed overflow.

  • Reading C = 1 after SUB as a borrow. In this course it means no borrow.

  • Reading C after a logic operation. It only means something after ADD or SUB.

Practice Carry flag (C)

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Carry flag (C) is taught in Adders and ALUs and Basic CPU / Computer Architecture.