bcctr

Branch Conditional to Count Register

bcctr BO, BI

Branches to the address in the Count Register (CTR) if the condition is met. Used for computed jumps and switch statements.

Details

The bcctr instruction conditionally branches to the address specified by the Count Register (CTR). It checks the Condition Register bit specified by BI+32 and the BO field to determine if the branch should occur. If the branch is taken, it updates the Next Instruction Address (NIA) and optionally the Link Register (LR).

Pseudocode Operation

if (Condition(BO, BI)) NIA <- CTR(0:61) || 00

Programming Note

When LK=1, the address of the next sequential instruction is placed in LR, making this a subroutine call. Use blr to return. CTR is decremented before the branch condition is tested; the branch is taken only if the combined CTR-and-condition test passes. Do not use this instruction inside a loop that also modifies CTR.

Example

bcctr 20, 0

Encoding

Binary Layout
19
0
BO
6
BI
11
000
16
528
21
LK
31
 
Format XL-form
Opcode 0x4C000420
Extension Base
Registers Altered CTR

Operands

  • BO
    Branch Options
  • BI
    CR Bit Index