The Carry Flag
The Carry flag is a bit which indicates if the result of an operation results in a value greater than 255 or less than 0. The flag will change state on both accumulator and X register operations.
Examples
Example 1
{
LDA #0
CMP #5 //0-5=-5, Carry flag is set
BRC WillBranch
LDA #255
INC //255+1=256, Carry flag is set
BRC WillBranch
LDA #200
ADD #70 //200+70=270, Carry flag is set
BRC WillBranch
LDA #0
DEC //0-1=-1, Carry flag is set
BRC WillBranch
LDA #10
CMP #5 //10-5=5, Carry flag is cleared
BCC WillBranch
LDA #10
DEC //10-1=9, Carry flag is cleared
BRC WillNotBranch
INC //9+1=10, Carry flag is still cleared
BCC WillBranch
LDX #0
CMPX #5 //0-5=-5, Carry flag is set
BRC WillBranch
}
Example 2
Task1()
{
Name="Dipswitch checker" //Branches on the highest dipswitch set
LDA ^59,0 //Get the dipswitch port
ROL //Move Dipswitch 8 into the carry flag
BRC DipSwitch8Set //If carry flag is set branch.
ROL //Move next Dipswitch into the carry flag
BRC DipSwitch7Set //If carry flag is set branch.
...
}