b (Branch) instruction

Purpose

Branches to a specified target address.

Syntax

Bits Value
0 - 5 18
6 - 29 LL
30 AA
31 LK

Description

The b instruction branches to an instruction specified by the branch target address. The branch target address is computed one of two ways.

Consider the following when using the b instruction:

  • If the Absolute Address bit (AA) is 0, the branch target address is computed by concatenating the 24-bit LI field. This field is calculated by subtracting the address of the instruction from the target address and dividing the result by 4 and b'00'. The result is then sign-extended to 32 bits and added to the address of this branch instruction.
  • If the AA bit is 1, then the branch target address is the LI field concatenated with b'00' sign-extended to 32 bits. The LI field is the low-order 26 bits of the target address divided by four.

The b instruction has four syntax forms. Each syntax form has a different effect on the Link bit and Link Register.

Item Description
Syntax Form Absolute Address Bit (AA) Fixed-Point Exception Register Link Bit (LK) Condition Register Field 0
b 0 None 0 None
ba 1 None 0 None
bl 0 None 1 None
bla 1 None 1 None

The four syntax forms of the b instruction never affect the Fixed-Point Exception Register or Condition Register Field 0. The syntax forms set the AA bit and the Link bit (LK) and determine which method of calculating the branch target address is used. If the Link bit (LK) is set to 1, then the effective address of the instruction is placed in the Link Register.

Parameters

Item Description
target_address Specifies the target address.

Examples

  1. The following code transfers the execution of the program to there:
    
    here: b there
          cror 31,31,31
    # The execution of the program continues at there.
    there:
    
  2. The following code transfers the execution of the program to here and sets the Link Register:
    
            bl here
    return: cror 31,31,31
    # The Link Register now contains the address of return.
    # The execution of the program continues at here.
    here: