Converting existing programs

Keeping in mind that 31-bit addressing mode programs can reside either below or above 16 megabytes, you can convert existing programs as follows:
  1. Converting the program to use 31-bit addresses - a change in addressing mode only.
    • You can change the entire module to use 31-bit addressing.
    • You can change only that portion that requires 31-bit addressing mode execution.

    Be sure to consider whether or not the code has any dependencies on 24-bit addresses. Such code does not produce the same results in 31-bit mode as it did in 24-bit mode. See Mode sensitive instructions for an overview of instructions that function differently depending on addressing mode.

    Figure 1 summarizes the things that you need to do to maintain the proper interface with a program that you plan to change to 31-bit addressing mode.
    Figure 1. Maintaining Correct Interfaces to Modules that Change to AMODE 31
    ieaa6mci
  2. Moving the program above 16 megabytes - a change in both addressing mode and residency mode
In general, you move an existing program above 16 megabytes because there is not enough room for it below 16 megabytes. For example:

The techniques used to establish proper interfaces to modules that move above 16 megabytes depend on the number of callers and the ways they invoke the module. Table 1 summarizes the techniques for passing control. The programs involved must ensure that any addresses passed as parameters are treated correctly. (High-order bytes of addresses to be used by a 31-bit addressing mode program must be validated or zeroed.)

Table 1. Establishing Correct Interfaces to Modules That Move Above 16 Megabytes
Means of Entry to Moved Module (AMODE 31,RMODE ANY) Few AMODE 24,RMODE 24 Callers Many AMODE 24,RMODE 24 Callers
LOAD macro and BALR
  • Have caller use LINK OR LINKX

       or

  • Have caller use LOAD macro and BASSM (invoked program returns via BSM)

       or

  • Change caller to AMODE 31,RMODE 24 before BALR
Create a linkage assist routine (described in Establishing linkage). Give the linkage assist routine the name of the moved module.
BALR using an address in a common control block
  • Have caller switch to AMODE 31 when invoking

       or

  • Change the address in the control block to a pointer-defined value (described in Establishing linkage) and use BASSM. (The moved module will use BSM to return.)
Create a linkage assist routine (described in Establishing linkage).
ATTACH, ATTACHX, LINK, LINKX, XCTL, or XCTLX No changes required. No changes required.
SYNCH or SYNCHX in AMODE 24
  • Have caller use SYNCH or SYNCHX with AMODE=31 parameter

       or

  • Have caller switch to AMODE 31 before issuing SYNCH or SYNCHX.
  • Change address in the control block to a pointer-defined value and use SYNCH or SYNCHX with AMODE=DEFINED.
Create a linkage assist routine (described in Establishing linkage).
In deciding whether or not to modify a program to execute in 31-bit addressing mode either below or above 16 megabytes, there are several considerations:
  1. How and by what is the module entered?
  2. What system and user services does the module use that do not support 31-bit callers or parameters?
  3. What kinds of coding practices does the module use that do not produce the same results in 31-bit mode as in 24-bit mode?
  4. How are parameters passed? Can they reside above 16 megabytes?
Among the specific practices to check for are:
  1. Does the module depend on the instruction length code, condition code, or program mask placed in the high order byte of the return address register by a 24-bit mode BAL or BALR instruction? One way to determine some of the dependencies is by checking all uses of the SPM (set program mask) instruction. SPM might indicate places where BAL or BALR were used to save the old program mask, which SPM might then have reset. The IPM (insert program mask) instruction can be used to save the condition code and the program mask.
  2. Does the module use an LA instruction to clear the high-order byte of a register? This practice will not clear the high-order byte in 31-bit addressing mode.
  3. Are any address fields that are less than 4 bytes still appropriate? Make sure that a load instruction does not pick up a 4-byte field containing a 3-byte address with extraneous data in the high-order byte. Make sure that bits 1-7 are zero.
  4. Does the program use the ICM (insert characters under mask) instruction? The use of this instruction is sometimes a problem because it can put data into the high-order byte of a register containing an address, or it can put a 3-byte address into a register without first zeroing the register. If the register is then used as a base, index, or branch address register in 31-bit addressing mode, it might not indicate the proper address.
  5. Does the program invoke 24-bit addressing mode programs? If so, shared data must be below 16 megabytes.
  6. Is the program invoked by 24-bit or 31-bit addressing mode programs? Is the data in an area addressable by the programs that need to use it? (The data must be below 16 megabytes if used by a 24-bit addressing mode program.)