Difference between revisions of "Carry Flag"

From Intellivision Wiki
Jump to: navigation, search
Line 2: Line 2:
 
The Carry Flag (C), if set, indicates that the previous operation resulted in an unsigned integer overflow.  If clear, the previous operation did not result in an unsigned integer overflow.<br/><br/>
 
The Carry Flag (C), if set, indicates that the previous operation resulted in an unsigned integer overflow.  If clear, the previous operation did not result in an unsigned integer overflow.<br/><br/>
  
For unsigned addition, the Carry is set when the addition's result is larger than what would fit in a 16-bit register, and cleared otherwise.  For unsigned subtraction, the Carry is set whenever the minuend (the first number) is greater than or equal to the subtrahend (the second number), and cleared otherwise.  (In essence, it indicates "Did Not Borrow.")  Since the CMP family of instructions compare numbers by subtracting them, one sometimes sees [[BC|Branch if Carry set]] described as an unsigned variation of "Branch if Greater-than or Equal"  (sometimes seen as BHIS: Branch if HIgher or Same), and [[BNC|Branch if No Carry set]] described as an unsigned variation of "Branch if Less-than" (sometimes seen as BLO:  Branch if LOwer).<br/><br/>
+
For unsigned addition, the Carry is set when the addition's result is larger than what would fit in a 16-bit register, and cleared otherwise.  For unsigned subtraction, the Carry is set whenever the minuend (the first number) is greater than or equal to the subtrahend (the second number), and cleared otherwise.  (In essence, it indicates "Did Not Borrow.")  The Carry bit can be used in conjunction with ADCR to perform [[Extended Precision Arithmetic]].<br/><br/>
 +
 
 +
Since the CMP family of instructions compare numbers by subtracting them, one sometimes sees [[BC|Branch if Carry set]] described as an unsigned variation of "Branch if Greater-than or Equal"  (also BHIS: Branch if HIgher or Same), and [[BNC|Branch if No Carry set]] described as an unsigned variation of "Branch if Less-than" (also BLO:  Branch if LOwer).  The names BHIS and BLO come from the PDP-11.<br/><br/>
  
 
The behavior of the following opcodes is affected by the status of the Carry Flag.<br/>
 
The behavior of the following opcodes is affected by the status of the Carry Flag.<br/>

Revision as of 23:43, 11 January 2005

The Carry Flag (C), if set, indicates that the previous operation resulted in an unsigned integer overflow. If clear, the previous operation did not result in an unsigned integer overflow.

For unsigned addition, the Carry is set when the addition's result is larger than what would fit in a 16-bit register, and cleared otherwise. For unsigned subtraction, the Carry is set whenever the minuend (the first number) is greater than or equal to the subtrahend (the second number), and cleared otherwise. (In essence, it indicates "Did Not Borrow.") The Carry bit can be used in conjunction with ADCR to perform Extended Precision Arithmetic.

Since the CMP family of instructions compare numbers by subtracting them, one sometimes sees Branch if Carry set described as an unsigned variation of "Branch if Greater-than or Equal" (also BHIS: Branch if HIgher or Same), and Branch if No Carry set described as an unsigned variation of "Branch if Less-than" (also BLO: Branch if LOwer). The names BHIS and BLO come from the PDP-11.

The behavior of the following opcodes is affected by the status of the Carry Flag.

BC
BNC
BUSC
BESC
ADCR
GSWD
RLC*
RRC*

In addition to affecting the behavior of the opcodes above, the following opcodes affect the status of the Carry Flag.

CLRC
SETC
NEGR
ADCR
RSWD*
RRC*
RLC*
SARC*
SLLC*
ADDR
SUBR
CMPR
ADD
ADD@
SUB
SUB@
CMP
CMP@

  • Indicates slight variation from normal Carry Flag behavior. See opcode documentation for more details.