Using an ADCON to obtain a pointer-defined value

The following method is useful when you need to construct pointer-defined values to use in pointer-defined linkages between control sections or modules that will be link edited into a single load module. You can also use this method when the executable program is prepared in storage using the loader.

The method requires the use of an externally-defined address constant in the routine to be invoked that identifies its entry mode and address. The address constant must contain a pointer-defined value. The calling program loads the pointer-defined value and uses it in a BASSM instruction. The invoked routine returns using a BSM instruction.

In Figure 1, RTN1 obtains pointer-defined values from RTN2 and RTN3. RTN1, the invoking routine does not have to know the addressing modes of RTN2 and RTN3. Later, RTN2 or RTN3 could be changed to use different addressing modes, and at that time their address constants would be changed to correspond to their new addressing mode. RTN1, however, would not have to change the sequence of code it uses to invoke RTN2 and RTN3.

You can use the techniques that the previous example illustrates to handle routines that have multiple entry points (possibly with different AMODE attributes). You need to construct a table of address constants, one for each entry point to be handled.

As with all forms of linkage, there are considerations in addition to the linkage mechanism. These include:

When a 24-bit addressing mode program invokes a module that is to execute in 31-bit addressing mode, the calling program must ensure that register 13 contains a valid 31-bit address of the register save area with no extraneous data in bits 1-7 of the high-order byte. In addition, when any program invokes a 24-bit addressing mode program, register 13 must point to a register save area located below 16 megabytes.

Figure 1. Example of Pointer-Defined Linkage
RTN1  CSECT
      EXTRN   RTN2AD
      EXTRN   RTN3AD
      .
      .
      L       15,=A(RTN2AD)   LOAD ADDRESS OF POINTER-DEFINED VALUE
      L       15,0(,15)       LOAD POINTER-DEFINED VALUE
      BASSM   14,15           GO TO RTN2 VIA BASSM
      .
      .
      L       15,=A(RTN3AD)   LOAD ADDRESS OF POINTER-DEFINED VALUE
      L       15,0(,15)       LOAD POINTER DEFINED-VALUE
      BASSM   14,15           GO TO RTN3 VIA BASSM
      .

__________________________________________________________________
RTN2   CSECT
RTN2   AMODE   24
       ENTRY   RTN2AD
       .
       BSM     0,14           RETURN TO CALLER IN CALLER'S MODE
RTN2AD DC      A(RTN2)        WHEN USED AS A POINTER-DEFINED VALUE,
                              INDICATES AMODE 24 BECAUSE BIT 0 IS 0

__________________________________________________________________
RTN3   CSECT
RTN3   AMODE  31
       ENTRY  RTN3AD
       .
       BSM    0,14                RETURN TO CALLER IN CALLER'S MODE
RTN3AD DC     A(X'80000000'+RTN3) WHEN USED AS A POINTER-DEFINED VALUE
                                  INDICATES AMODE 31 BECAUSE BIT 0 IS 1