BCC Label - Branch if carry flag is cleared

Branches if the carry flag is not set (cleared). The carry flag is cleared when the result of an operation results in a value greater between 0 and 255 (0xff).
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.
This is the opposite of the BRC command.

Syntax

BCC Label
Where "Label" is the label name to where you want it to branch if the carry flag is cleared. It is handy for checking a threshold or interrogating individual bits in a byte.

Ways to clear the Carry Flag
  • CMP Command Comparing a smaller value to a larger accumulator value

  • ADD Command that results in a value less than 255

  • SUB Command that results in a value greater than 0

  • INC Command with a value less than 255 in the accumulator

  • DEC Command with greater than 0 in the accumulator

  • SHL Command with an accumulator value below 128 (MSB Cleared)

  • SHR Command with an even value in the accumulator (LSB Cleared)

  • ROL Command with an accumulator value below 128 (MSB Cleared)

  • ROR Command with an even value in the accumulator (LSB Cleared)

  • DIV Command always clears all flags

  • MUL Command clears the carry and minus flags

Examples

Example 1

Ways to clear the carry flag.

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

LDA #100    //Load a fixed decimal value of 100
ADD #100    //Add a fixed decimal value of 100, 100+100=200, Carry flag will be cleared
BCC NotTooMuch //The carry flag is set so the task will branch to the label

DIV         //Always clears all flags

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

Example 2

Using Carry flag to check a threshold.

{
LDA #0                  //Clear the timer.
STA ~11                 //Store it
Loop:
    LDA ~11             //Load the current timer
	CMP #MaxDuration    //Have we exceeded the max duration?
	BCC TurnOnLights    //If we have exceeded the threshold turn on the lights.
    INC                 //Increase timer by 1.
    Delay(60)           //Wait a minute.
    STA ~11             //Store into the timer
    BRA Loop            //Go check again.
    Null
    TurnOnLights:
        Preset(A=100,P=1)//Turn on the lights
        Null
}

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.
BCC Dip1Cleared //Branch if dipswitch one is cleared. If not assume set.
...
}