bcctr
Branch Conditional to Count Register
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
Encoding
Operands
-
BO
Branch Options -
BI
CR Bit Index