Carry flag

In computer processors, the carry flag (usually indicated as the C flag) is a single bit in a system status register/flag register used to indicate when an arithmetic carry or borrow has been generated out of the most significant arithmetic logic unit (ALU) bit position.

[1] It is also used to extend bit shifts and rotates in a similar manner on many processors (sometimes done via a dedicated flag).

The carry flag is affected by the result of most arithmetic (and typically several bitwise) instructions and is also used as an input to many of them.

[2] The use of the carry flag in this manner enables multi-word add, subtract, shift, and rotate operations.

If 11111111 represents two's complement signed integer −1 (ADD al,-1), then the interpretation of the result is -2 because Overflow_Flag is clear, and Carry_Flag is ignored.

The carry flag is also often used following comparison instructions, which are typically implemented by subtractive operations, to allow a decision to be made about which of the two compared values is lower than (or greater or equal to) the other.

When used in this way the carry flag provides a mechanism for comparing the values as unsigned integers.

The VAX, NS320xx, Fairchild Clipper and Atmel AVR architectures use the borrow bit convention, but call their a−b−C operation "subtract with carry" (SBWC, SUBC, SUBWC and SBC).

The PA-RISC and PICmicro architectures use the carry bit convention, but call their a+not(b)+C operation "subtract with borrow" (SUBB and SUBWFB).