HLASM - BALR = Branch And Link Register

The opcode of the BALR instruction is X'05'.

Usage

  1. Branch to a subroutine in a different CSECT - provided that it can be invoked in the same addressing mode as the caller. In this case R14 and R15 are usually used for the return address and destination address respectively.
  2. Branch to a subroutine in the same CSECT - provided that it can be invoked in the same addressing mode as the caller, which will normally be the case. It is not unusual to use other (less volatile) registers than R14 and R15 in this case.
  3. Obtain addressability to the current routine.

Arguments

  1. Register to receive the return address.
  2. Register holding the destination address.

Function

  1. The processor places the address of the byte following the BALR instruction (which is both the next sequential instruction address and the expected return address) in the first register.
  2. It branches to the address specified in the second register.
  3. The condition code does not change.

Special Cases

  1. If the second argument is register 0, then no branch will be taken; only the return information is placed in the first register.

Related Instructions

  1. BAL branches to a routine that is directly addressable in base-displacement form.
  2. BCR is the preferred return instruction.
  3. BASR is preferred over BALR.
  4. BASSM branches to another routine that may need to be called in a different Amode.

Hardware

  1. All hardware supports the BALR instruction.

Remarks

  1. The PSW's Amode setting determines how many bits are used for the return and destination addresses.
  2. Use of BALR is discouraged. Use BASR instead.
  3. In Amode 24 the generated return address contains 8 high-order bits with additional PSW fields. This is usually regarded as garbage. The high-order bit of the 32-bit register may be set to one, which may cause problems if the called program returns with a BSM instead of one of the BCR instructions (typically BR instruction).

Terms Explained

Examples

         YREGS                          * Define register names
ENTRY    BALR  R15,R0                   * Obtain routine address
USEBASE  USING USEBASE,R15              * Make code addressable
         ...
         L     R15,=V(SUBPROG)          * Load address of subroutine
         BALR  R14,R15                  * Call subprogram
         ...

To the Opcodes Overview.
To the English Homepage for Hlasm.com.
To the General Homepage for Bixoft and Hlasm.com.

This site is a member of WebRing.
You are invited to browse the list of mainframe-loving sites.
Running Tyrannosaurus Rex Dinos are not dead. They are alive and well and living in data centers all around you. They speak in tongues and work strange magics with computers. Beware the dino! And just in case you're waiting for the final demise of these dino's: remember that dinos ruled the world for 155-million years!
Dinos and other anachronisms
[ Join Now | Ring Hub | Random | << Prev | Next >> ]
 

Below you find the logo of our sponsor and logos of the web-standards that this page adheres to.