BCS Instruction (Branch if Carry is Set/ Branch if Greater Than or Equal)

If the carry flag is set, changes the execution position to the specified location.
BGE is an alias of BCS.

BCS Overloads

OpcodeSyntaxAddressing ModeBytesCyclesNotes
B0BCS near
BGE near
PC Rel.221, 2

Notes

  1. Add 1 cycle if the branch is actually taken
  2. Add 1 cycle in emulation mode if the branch target crosses a page boundary

Flags Affected

--------

This instruction does not change the status flags.

Description

If the carry flag is set, the BCS instruction changes the program’s execution position to the address indicated by the signed 8-bit offset given as the operand, relative to the current program counter.
It is normally executed together with a comparison such as the CMP instruction, but depending on the purpose it may be used together with other instructions.

Examples

Branching on unsigned magnitude

After a CMP instruction, the carry flag is set when “A is greater than or equal to the compared value”.

    LDA $10
    CMP.b #$20
    BCS .ge         ; branch when $10 >= $20 (unsigned)
    ; we get here when $10 < $20

Receiving a subroutine’s result

The carry flag is also often used to return a subroutine’s success or failure (see the CLC instruction).

    JSR CheckHit
    BCS .hit        ; a hit if it returns with the carry set

See also

BCC instruction
BEQ instruction
BMI instruction
BNE instruction
BPL instruction
BRA instruction
BRL instruction
BVC instruction
BVS instruction