Modern Linkage Instructions

For program linkage, the Branch-And-Link instructions BAL and BALR are replaced by the Branch-and-Save instructions BAS and BASR.  The Branch-On-Condition instruction BR is replaced by Branch-And-Set-Mode BSM.

         BALR  R14,R15           CHECKS AMODE, IF AMODE(24)
*        .                         R14 BITS 0-7  <- ILC, CC, PROG MASK
*        .                         R14 BITS 8-31 <- 24-BIT ADDR
*        .
         BR    R14               RETURN TO CALLER
*
*
         BASR  R14,R15           NO AMODE CHECK
*        .                         R14 BIT  0    <- PSW BIT 32 (AMODE)
*        .                         R14 BITS 1-31 <- 31-BIT ADDR
*        .
         BSM   0,R14             RETURN AND ALSO SET AMODE

The BSM instruction may not be used to return control from an AMODE(31) program to an AMODE(24) program unless an AMODE(24) “glue” module was used as an intermediary between the AMODE(24) program and the AMODE(31) program.

Old Program - gives control to “Glue” Module
         L      R15,=V(GLUEMOD)  R15 <- GLUE MODULE ENTRY
         BALR   R14,R15          BRANCH TO GLUE MODULE

“Glue” Module - saves AMODE and gives control to New Program
         L      R15,=V(NEWPROG)  R15 <- GLUE MODULE ENTRY, AMODE(31)
         BSM    R14,R15          R14 BIT-0 <- CURRENT PSW BIT 32
*                                PSW BITS 32-63 <- R15

New Program - Resets AMODE and returns directly to Old Program
         BSM    0,R14            SET AMODE(24) & RETURN TO OLD PROG

The Branch-And-Save-And-Set-Mode instruction BASSM combines the effects of the BASR and BSM instructions, saving current AMODE and link address, and setting new AMODE and branching.  With a small modification, an old, AMODE(24) program may exchange control with a new, AMODE(31) program.

Old Program - gives control directly to New Program
         L      R15,=V(NEWPROG)  R15 <- NEW PROGRAM ENTRY & AMODE
         BASSM  R14,R15          R14 BIT  0     <- PSW BIT 32 (AMODE)
*                                R14 BITS 1-7   <- B'0'
*                                R14 BITS 8-31  <- 24-BIT RETURN ADDR
*                                PSW BITS 32-63 <- R15

New Program - Resets AMODE and returns to Old Program
         BSM    0,R14            PSW BITS 32-63 <- R14

Copyright © 2006 The Stevens Computing Services Company, Inc.  All rights reserved.