Passing control between programs with different AMODEs

If you are passing control between programs executing in different addressing modes, you must change the AMODE indicator in the PSW. The BASSM and BSM instructions perform this function for you. You can transfer to a program in another AMODE using a BASSM instruction and then return by means of a BSM instruction. This sequence of instructions ensures that both programs execute in the correct AMODE.

Figure 1 shows an example of passing control between programs with different addressing modes. In the example, TEST executes in 24-bit AMODE and EP1 executes in 31-bit AMODE. Before transferring control to EP1, the TEST program loads register 15 with EPA, the pointer defined entry point address (that is, the address of EP1 with the high order bit set to 1 to indicate 31-bit AMODE). This is followed by a BASSM 14,15 instruction, which performs the following functions:
The EP1 program executes in 31-bit AMODE. Upon completion, EP1 sets a return code in register 15 and executes a BSM 0,14 instruction, which performs the following functions:
Figure 1. Example of Addressing Mode Switch
TEST    CSECT
TEST    AMODE   24
TEST    RMODE   24
        .
        .
        L       15,EPA     OBTAIN TRANSFER ADDRESS
        BASSM   14,15      SWITCH AMODE AND TRANSFER
        .
        .
        EXTRN   EP1
EPA     DC      A(X'80000000'+EP1) POINTER DEFINED ENTRY POINT ADDRESS
        .
        .
        END
____________________________________________________________
EP1     CSECT
EP1     AMODE   31
EP1     RMODE   ANY
        .
        .
        SLR     15,15      SET RETURN CODE 0
        BSM     0,14       RETURN TO CALLER'S AMODE AND TRANSFER
        END