bclr
Branch Conditional to Link Register - 4C 00 00 20
bclr

Instruction Syntax

Mnemonic Format Flags
bclr BO,BI LK = 0
bclrl BO,BI LK = 1

Derived Forms

Mnemonic Format Equivalent
blr bclr 20,0
blrl bclrl 20,0

Instruction Encoding

0
1
0
0
1
1
B
B
B
B
B
B
B
B
B
B
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
L

Field Bits Description
Primary Opcode 0-5 010011 (0x13)
BO 6-10 Branch Options
BI 11-15 Branch Condition Index
Reserved 16-20 00000
XO 21-30 0000010000 (16)
LK 31 Link Register Update

Operation

cond_ok ← BO[0] | (CR[BI] ≡ BO[1])
if cond_ok then NIA ← LR[0-29] || '00'
if LK = 1 then LR ← CIA + 4

Branch conditional to link register instruction branches to the address in the link register if the condition is met. The low-order 2 bits of the link register are ignored to ensure word alignment.

Note: If LK = 1, the link register is updated with the current instruction address + 4 before branching.

Affected Registers

Link Register (LR)

(if LK = 1)

For more information on branching see Section 2.3, "Branch Processor," in the PowerPC Microprocessor Family: The Programming Environments manual.

Examples

Simple Function Return

# Most common use - function return
blr                      # Return to caller (bclr 20,0)

Conditional Function Return

cmpwi r3, 0              # Test return value
bclr 12, 2               # Return early if zero
# additional processing here
blr                      # Normal return

Function with Early Exit

my_function:
    cmpwi r3, 0          # Check parameter
    bclr 12, 2           # Return if parameter is 0
    
    # Function body here
    addi r3, r3, 1       # Increment parameter
    
    blr                  # Normal return

Link Register Chain

# Save and restore link register
mflr r0                  # Save current LR
stw r0, 4(r1)           # Store on stack
bl subroutine           # Call subroutine
lwz r0, 4(r1)           # Restore LR from stack
mtlr r0                 # Move back to LR
blr                     # Return to original caller

Conditional Subroutine Call with Return

cmpwi r3, 1              # Test condition
bclrl 12, 2              # Call subroutine conditionally (saves new LR)
# continues here if condition false or after return

Loop Counter with Return

countdown_loop:
    cmpwi r3, 0          # Check counter
    bclr 12, 2           # Return if counter is zero
    subi r3, r3, 1       # Decrement counter
    bl process_item      # Process current item
    b countdown_loop     # Loop back

Related Instructions

b, bc, bcctr

Back to Index