bl

Branch and Link

bl target_addr

Branches to a target address and saves the return address (CIA + 4) in the Link Register (LR). Used for function calls.

Details

Branches to a target address calculated from the 24-bit signed immediate and saves the return address (CIA + 4) in the Link Register (LR). The AA bit determines whether the address is absolute or relative. This is the standard instruction for subroutine calls.

Pseudocode Operation

if AA = 0 then NIA ← CIA + (LI || 0b00) else NIA ← (LI || 0b00)
LR ← CIA + 4

Programming Note

The bl instruction is commonly used for function calls where a return to the caller is required. Ensure that the target address is correctly calculated and aligned, as misalignment can lead to exceptions. The link register (LR) must be preserved if nested subroutine calls are made to maintain correct return paths.

Example

bl printf

// Call 'printf' function.

Encoding

Binary Layout
18
0
LI
6
AA
30
1
31
 
Format I-form
Opcode 0x48000001
Extension Base
Registers Altered LR

Operands

  • LI
    24-bit Signed Immediate