blr
Branch to Link Register - 4E 80 00 20
blr
Instruction Syntax
Mnemonic | Format | Flags |
blr | LK = 0 | |
blrl | LK = 1 |
Note: BLR is a derived form of BCLR with BO=20 and BI=0, meaning it always branches (unconditional).
Instruction Encoding
0
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Field | Bits | Description |
Primary Opcode | 0-5 | 010011 (0x13) |
BO | 6-10 | Branch Option (20 = always branch) |
BI | 11-15 | Branch Input (0 = not used) |
LK | 31 | Link (0 = no link, 1 = link) |
Operation
if (LK == 0) then NIA ← LR else NIA ← LR LR ← CIA + 4
Branch to the address contained in the Link Register (LR). If LK=1, the address of the instruction following the BLR is placed into LR.
Affected Registers
Link Register (LR)
(if LK = 1)
- Updated with the address of the instruction following BLR
Next Instruction Address (NIA)
- Set to the value in LR
Examples
Function Return
# Standard function return blr # Return to caller blrl # Return and set LR for next call
Subroutine Call and Return
# Call a subroutine bl my_function # Branch and link to function # ... function code ... blr # Return to caller
Conditional Return
# Return only if condition is met cmpwi r3, 0 # Compare r3 with 0 beq return # Branch if equal # ... continue processing ... return: blr # Return to caller