Establishing a base register

Each program must establish a base register immediately after it saves the calling program's registers. When selecting a base register, keep in mind that:

Register 12 is generally a good choice for base register when not writing an LE-conforming assembler program.

Your program should use the relative and immediate instruction set and thus not need code addressability in general. If the program is AMODE 64, this is expected. But the program does need to establish addressability to any static data that it might need. The program might also need temporary code addressability when invoking system macros. Macros such as STORAGE require the invoker to have code addressability surrounding the macro invocation. Nevertheless, you should also help out system macros by identifying the architecture level under which your program is known to run. SYSSTATE ARCHLVL=2 can be used for all programs that run only on supported z/OS releases.

When your program is entered in one AMODE and will change to another, be sure to set your base registers properly for the eventual AMODE. For example, suppose that your program is entered in AMODE 31 and will switch to AMODE 64. If you use the LA or LARL instruction to set the base register while in AMODE 31, that will not clear bits 0-31 of the 64-bit register. All 64 bits must be set properly when being used in AMODE 64. After the LA or LARL, you could use the LLGTR instruction to clear bits 0-32 of the 64-bit register.