<s>
In	O
computer	O
processors	O
the	O
carry	B-Algorithm
flag	I-Algorithm
(	O
usually	O
indicated	O
as	O
the	O
C	O
flag	O
)	O
is	O
a	O
single	O
bit	O
in	O
a	O
system	O
status	O
register/flag	O
register	O
used	O
to	O
indicate	O
when	O
an	O
arithmetic	O
carry	B-Algorithm
or	O
borrow	O
has	O
been	O
generated	O
out	O
of	O
the	O
most	O
significant	O
arithmetic	B-General_Concept
logic	I-General_Concept
unit	I-General_Concept
(	O
ALU	O
)	O
bit	O
position	O
.	O
</s>
<s>
The	O
carry	B-Algorithm
flag	I-Algorithm
enables	O
numbers	O
larger	O
than	O
a	O
single	O
ALU	O
width	O
to	O
be	O
added/subtracted	O
by	O
carrying	O
(	O
adding	O
)	O
a	O
binary	O
digit	O
from	O
a	O
partial	O
addition/subtraction	O
to	O
the	O
least	O
significant	O
bit	O
position	O
of	O
a	O
more	O
significant	O
word	O
.	O
</s>
<s>
This	O
is	O
typically	O
programmed	O
by	O
the	O
user	O
of	O
the	O
processor	O
on	O
the	O
assembly	O
or	O
machine	O
code	O
level	O
,	O
but	O
can	O
also	O
happen	O
internally	O
in	O
certain	O
processors	O
,	O
via	O
digital	O
logic	O
or	O
microcode	B-Device
,	O
where	O
some	O
processors	O
have	O
wider	O
registers	O
and	O
arithmetic	O
instructions	O
than	O
(	O
combinatorial	O
,	O
or	O
"	O
physical	O
"	O
)	O
ALU	O
.	O
</s>
<s>
For	O
subtractive	O
operations	O
,	O
two	O
(	O
opposite	O
)	O
conventions	O
are	O
employed	O
as	O
most	O
machines	O
set	O
the	O
carry	B-Algorithm
flag	I-Algorithm
on	O
borrow	O
while	O
some	O
machines	O
(	O
such	O
as	O
the	O
6502	B-General_Concept
and	O
the	O
PIC	B-Architecture
)	O
instead	O
reset	O
the	O
carry	B-Algorithm
flag	I-Algorithm
on	O
borrow	O
(	O
and	O
vice	O
versa	O
)	O
.	O
</s>
<s>
The	O
carry	B-Algorithm
flag	I-Algorithm
is	O
affected	O
by	O
the	O
result	O
of	O
most	O
arithmetic	O
(	O
and	O
typically	O
several	O
bit	O
wise	O
)	O
instructions	O
and	O
is	O
also	O
used	O
as	O
an	O
input	O
to	O
many	O
of	O
them	O
.	O
</s>
<s>
Several	O
of	O
these	O
instructions	O
have	O
two	O
forms	O
which	O
either	O
read	O
or	O
ignore	O
the	O
carry	B-Algorithm
.	O
</s>
<s>
In	O
assembly	B-Language
languages	I-Language
these	O
instructions	O
are	O
represented	O
by	O
mnemonics	O
such	O
as	O
ADD/SUB	O
,	O
ADC/SBC	O
(	O
ADD/SUB	O
including	O
carry	B-Algorithm
)	O
,	O
SHL/SHR	O
(	O
bit	O
shifts	O
)	O
,	O
ROL/ROR	O
(	O
bit	O
rotates	O
)	O
,	O
RCR/RCL	O
(	O
rotate	O
through	O
carry	B-Algorithm
)	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
The	O
use	O
of	O
the	O
carry	B-Algorithm
flag	I-Algorithm
in	O
this	O
manner	O
enables	O
multi-word	O
add	O
,	O
subtract	O
,	O
shift	O
,	O
and	O
rotate	O
operations	O
.	O
</s>
<s>
The	O
8	O
least	O
significant	O
bits	O
always	O
stored	O
in	O
the	O
register	B-General_Concept
would	O
be	O
11111110	O
binary	O
(	O
254	O
decimal	O
)	O
but	O
since	O
there	O
is	O
carry	B-Algorithm
out	O
of	O
bit	O
7	O
(	O
the	O
eight	O
bit	O
)	O
,	O
the	O
carry	B-Algorithm
is	O
set	O
,	O
indicating	O
that	O
the	O
result	O
needs	O
9	O
bits	O
.	O
</s>
<s>
The	O
valid	O
9-bit	O
result	O
is	O
the	O
concatenation	O
of	O
the	O
carry	B-Algorithm
flag	I-Algorithm
with	O
the	O
result	O
.	O
</s>
<s>
For	O
x86	B-Operating_System
ALU	O
size	O
of	O
8	O
bits	O
,	O
an	O
8-bit	O
two	O
's	O
complement	O
interpretation	O
,	O
the	O
addition	O
operation	O
11111111	O
+	O
11111111	O
results	O
in	O
111111110	O
,	O
Carry_Flag	O
set	O
,	O
Sign_Flag	O
set	O
,	O
and	O
Overflow_Flag	O
clear	O
.	O
</s>
<s>
Another	O
example	O
may	O
be	O
an	O
8-bit	O
register	B-General_Concept
with	O
the	O
bit	O
pattern	O
01010101	O
and	O
the	O
carry	B-Algorithm
flag	I-Algorithm
set	O
;	O
if	O
we	O
execute	O
a	O
rotate	O
left	O
through	O
carry	B-Algorithm
instruction	O
,	O
the	O
result	O
would	O
be	O
10101011	O
with	O
the	O
carry	B-Algorithm
flag	I-Algorithm
cleared	O
because	O
the	O
most	O
significant	O
bit	O
(	O
bit	O
7	O
)	O
was	O
rotated	O
into	O
the	O
carry	B-Algorithm
while	O
the	O
carry	B-Algorithm
was	O
rotated	O
into	O
the	O
least	O
significant	O
bit	O
(	O
bit	O
0	O
)	O
.	O
</s>
<s>
The	O
early	O
microprocessors	O
Intel	B-General_Concept
4004	I-General_Concept
and	O
Intel	B-General_Concept
8008	I-General_Concept
had	O
specific	O
instructions	O
to	O
set	O
as	O
well	O
as	O
reset	O
the	O
carry	B-Algorithm
flag	I-Algorithm
explicitly	O
.	O
</s>
<s>
However	O
,	O
the	O
later	O
Intel	B-General_Concept
8080	I-General_Concept
(	O
and	O
Z80	B-General_Concept
)	O
did	O
not	O
include	O
an	O
explicit	O
reset	O
carry	B-Algorithm
opcode	O
as	O
this	O
could	O
be	O
done	O
equally	O
fast	O
via	O
one	O
of	O
the	O
bitwise	O
AND	O
,	O
OR	O
or	O
XOR	O
instructions	O
(	O
which	O
do	O
not	O
use	O
the	O
carry	B-Algorithm
flag	I-Algorithm
)	O
.	O
</s>
<s>
The	O
carry	B-Algorithm
flag	I-Algorithm
is	O
also	O
often	O
used	O
following	O
comparison	O
instructions	O
,	O
which	O
are	O
typically	O
implemented	O
by	O
subtractive	O
operations	O
,	O
to	O
allow	O
a	O
decision	O
to	O
be	O
made	O
about	O
which	O
of	O
the	O
two	O
compared	O
values	O
is	O
lower	O
than	O
(	O
or	O
greater	O
or	O
equal	O
to	O
)	O
the	O
other	O
.	O
</s>
<s>
Branch	O
instructions	O
which	O
examine	O
the	O
carry	B-Algorithm
flag	I-Algorithm
are	O
often	O
represented	O
by	O
mnemonics	O
such	O
as	O
BCC	O
and	O
BCS	O
to	O
branch	O
if	O
the	O
carry	B-Algorithm
is	O
clear	O
,	O
or	O
branch	O
if	O
the	O
carry	B-Algorithm
is	O
set	O
respectively	O
.	O
</s>
<s>
When	O
used	O
in	O
this	O
way	O
the	O
carry	B-Algorithm
flag	I-Algorithm
provides	O
a	O
mechanism	O
for	O
comparing	O
the	O
values	O
as	O
unsigned	O
integers	O
.	O
</s>
<s>
This	O
is	O
in	O
contrast	O
to	O
the	O
overflow	B-Algorithm
flag	I-Algorithm
which	O
provides	O
a	O
mechanism	O
for	O
comparing	O
the	O
values	O
as	O
signed	O
integer	O
values	O
.	O
</s>
<s>
While	O
the	O
carry	B-Algorithm
flag	I-Algorithm
is	O
well-defined	O
for	O
addition	O
,	O
there	O
are	O
two	O
ways	O
in	O
common	O
use	O
to	O
use	O
the	O
carry	B-Algorithm
flag	I-Algorithm
for	O
subtraction	O
operations	O
.	O
</s>
<s>
The	O
8080	B-General_Concept
,	O
6800	B-Device
,	O
Z80	B-General_Concept
,	O
8051	B-Architecture
,	O
x86	B-Operating_System
and	O
68k	B-Device
families	O
(	O
among	O
others	O
)	O
use	O
a	O
borrow	O
bit	O
.	O
</s>
<s>
without	O
storing	O
the	O
carry	B-Algorithm
bit	I-Algorithm
inverted	O
)	O
and	O
computes	O
a−b	O
as	O
a+( not	O
b	O
)	O
+1	O
.	O
</s>
<s>
The	O
carry	B-Algorithm
flag	I-Algorithm
is	O
set	O
according	O
to	O
this	O
addition	O
,	O
and	O
subtract	O
with	O
carry	B-Algorithm
computes	O
a+	O
not(b )	O
+C	O
,	O
while	O
subtract	O
without	O
carry	B-Algorithm
acts	O
as	O
if	O
the	O
carry	B-Algorithm
bit	I-Algorithm
were	O
set	O
.	O
</s>
<s>
The	O
result	O
is	O
that	O
the	O
carry	B-Algorithm
bit	I-Algorithm
is	O
set	O
if	O
a≥b	O
,	O
and	O
clear	O
if	O
ab	O
.	O
</s>
<s>
The	O
System/360	B-Application
,	O
6502	B-General_Concept
,	O
MSP430	B-Architecture
,	O
COP8	B-Device
,	O
ARM	B-Architecture
and	O
PowerPC	B-Architecture
processors	I-Architecture
use	O
this	O
convention	O
.	O
</s>
<s>
The	O
6502	B-General_Concept
is	O
a	O
particularly	O
well-known	O
example	O
because	O
it	O
does	O
not	O
have	O
a	O
subtract	O
without	O
carry	B-Algorithm
operation	O
,	O
so	O
programmers	O
must	O
ensure	O
that	O
the	O
carry	B-Algorithm
flag	I-Algorithm
is	O
set	O
before	O
every	O
subtract	O
operation	O
where	O
a	O
borrow	O
is	O
not	O
required	O
.	O
</s>
<s>
Most	O
commonly	O
,	O
the	O
first	O
alternative	O
is	O
referred	O
to	O
as	O
a	O
"	O
subtract	O
with	O
borrow	O
"	O
,	O
while	O
the	O
second	O
is	O
called	O
a	O
"	O
subtract	O
with	O
carry	B-Algorithm
"	O
.	O
</s>
<s>
However	O
,	O
there	O
are	O
exceptions	O
in	O
both	O
directions	O
;	O
the	O
VAX	B-Device
,	O
NS320xx	B-Device
,	O
and	O
Atmel	B-Architecture
AVR	I-Architecture
architectures	O
use	O
the	O
borrow	O
bit	O
convention	O
,	O
but	O
call	O
their	O
a−b−C	O
operation	O
"	O
subtract	O
with	O
carry	B-Algorithm
"	O
(	O
SBWC	O
,	O
SUBC	O
and	O
SBC	O
)	O
.	O
</s>
<s>
The	O
PA-RISC	B-Device
and	O
PICmicro	B-Architecture
architectures	O
use	O
the	O
carry	B-Algorithm
bit	I-Algorithm
convention	O
,	O
but	O
call	O
their	O
a+	O
not(b )	O
+C	O
operation	O
"	O
subtract	O
with	O
borrow	O
"	O
(	O
SUBB	O
and	O
SUBWFB	O
)	O
.	O
</s>
<s>
The	O
ST6	B-Device
8-bit	O
microcontrollers	O
are	O
perhaps	O
the	O
most	O
confusing	O
of	O
all	O
.	O
</s>
<s>
Although	O
they	O
do	O
not	O
have	O
any	O
sort	O
of	O
"	O
subtract	O
with	O
carry	B-Algorithm
"	O
instruction	O
,	O
they	O
do	O
have	O
a	O
carry	B-Algorithm
bit	I-Algorithm
which	O
is	O
set	O
by	O
a	O
subtract	O
instruction	O
,	O
and	O
the	O
convention	O
depends	O
on	O
the	O
processor	O
model	O
.	O
</s>
<s>
The	O
ST60	O
processor	O
uses	O
the	O
"	O
carry	B-Algorithm
"	O
convention	O
,	O
while	O
the	O
ST62	O
and	O
ST63	O
processors	O
use	O
the	O
"	O
borrow	O
"	O
convention	O
.	O
</s>
