Rules for register usage

Many macro expansions include instructions that assume a base register previously defined by a USING statement. The USING statement must establish addressability so that the macro expansion can include a branch around the in-line parameter list, if present, and list the data fields and addresses specified in the macro operands.

Macros that use a BAL, BALR, BAS, or BASR instruction to pass control to an access method routine normally require that register 13 contain the address of an 18-word register-save area. The READ, WRITE, CHECK, GET, and PUT macros are of this type. If a macro requires a save area and your program calls the macro in 31-bit mode, the register 13 contents must be a valid 31-bit address and it may point above the 16 MB line.

Macros that use a supervisor call (SVC) instruction to pass control to an access method routine might modify general registers 0, 1, 14, and 15 without restoring them. Unless otherwise specified in the macro description, the contents of these registers are undefined when the system returns control to the problem program.

When an operand is specified as a register, the problem program must have inserted the value or address to be used into the register as follows:

Note that, if the macro accepts the RX-type address, an efficient way to clear the high-order part of a register is to code the parameter as 0(,reg) rather than merely as (reg). Then, the macro expands as:

LA parmreg,0(,reg) by macro rather than:

LA reg,0(,reg) by user and LR parmreg,reg by macro.

If your program is executing in 24-bit addressing mode, this clears the high-order byte. In 31-bit mode this clears the high order. You will get incorrect results if the number of the source register is zero.