BRC - Branch if carry flag set Command

Branches if the carry flag is set. The carry flag is set when the result of an operation results in a value greater than 255 (0xff) or if the result is less than zero.
This flag indicates that there is a value left over from a calculation or a value was borrowed for the calculation.
This flag can be set and cleared in a number of ways. It is handy for checking a threshold or interrogating individual bits in a byte.
This is the opposite of the BCC command.

Syntax

BRC Label
Where "Label" is the label name to where you want it to branch if the carry flag is set.

Ways to set the Carry Flag

Examples

Example 1

Ways to set the carry flag.

{
LDA #0x05   //put the fixed hex value 0x05 into the Accumulator.
CMP #0x06   //0x05-0x06 = -1 Set the Carry and Minus flags
BRC Label   //The carry flag is set so the task will branch to the label

LDA #100    //Load a fixed decimal value of 100
ADD #160    //Add a fixed decimal value of 160, 100+160=260, Carry flag will be set
BRC Greater //The carry flag is set so the task will branch to the label

LDA #0xFF   //Load a value of 255
INC         //Add 1, This will set the carry flag

LDA #0x00   //Load a value of 0
DEC         //Subtract 1, This will set the carry flag

LDA #133    //Load a value of 133
SHR         //Move the LSB into the carry flag, flag is set
}

Example 2

Using Carry flag to check a threshold.

{

...
Channel2Respond:
	LDA #NumberOfChannels   //Load the number of channels we are tracking.
	CMP #2					//Are we tracking 2 or less channels?
	BRC End	                //If we have exceeded the threshold end.
    ...

}

Example 3

Using Carry flag to interrogate the bits in a byte.

{
LDA ^59,0   //Load the dipswitch port
SHR         //Move dipswitch one value to the carry flag.
BRC Dip1Set //Branch if dipswitch one is set. If not assume cleared.
...

}