bclr
Branch Conditional to Link Register
bclrl BO,BI,BH
Branches to the address in the Link Register (LR) if the condition is met. Used for function returns.
Details
Branches to the address in the Link Register (LR) if the condition specified by BO and BI is satisfied. The CTR is decremented if BO[2]=0. If LK=1, the return address (CIA + 4) is saved in LR, enabling exception-safe subroutine returns. The BH field provides a branch prediction hint to the processor.
Pseudocode Operation
ctr_ok ← (BO[2] = 1) | (CTR ≠ 0 ⊕ BO[3])
if BO[2] = 0 then CTR ← CTR - 1
cr_ok ← (BO[0] = 1) | (CR[BI] = BO[1])
if ctr_ok & cr_ok then NIA ← LR[0:61] || 0b00
if LK = 1 then LR ← CIA + 4
Programming Note
bclr, bclrl, bcctr, and bcctrl each serve as both a basic and an extended mnemonic. The Assembler will recognize a bclr, bclrl, bcctr, or bcctrl mnemonic with three operands as the basic form, and a bclr, bclrl, bcctr, or bcctrl mnemonic with two operands as the extended form. In the extended form the BH operand is omitted and assumed to be 0b00.
Extended Mnemonics
| Extended Mnemonic | Equivalent Instruction |
|---|---|
| bcctr | |
| bltctr | |
| bnectr | |
| bclr | |
| bltlr | |
| bnelr | |
| bdnzlr | |
| bcctr | |
| bcctrl | |
| bclr 4,6 | |
| bnelr cr2 |
Example
// Unconditional return (blr).
Encoding
Operands
-
BO
Branch Options -
BI
CR Bit Index -
BH
Hint bits -
LK
Link Register Update field