This is the common notation in Principles of Operation for the computation of a storage address for a group of instructions collectively call RX instructions. D is 12-bit displacement, or offset, X and B refer to 32-bit registers. If X or B or 0, the register is not used. In RX instructions, the contents of the two registers are added together, and the 12-bit displacement is then added to the sum to compute a storage address.
The Assembler USING instruction establishes a storage location that is used as a base register to simplify most common addresses. For example -
USING BASE,10
L 5,DATA
...
BASE CSECT
DS XL12
DATA DS F
L 5,DATA
...
BASE CSECT
DS XL12
DATA DS F
Most of my programs start off with some combination of instruction similar to this.
PROGRAM CSECT
USING *,12
SAVE (14,12),,*
LR 12,15
LA 15,SAVEAREA
ST 13,4(,15)
ST 15,8(,13)
LR 13,15
USING *,12
SAVE (14,12),,*
LR 12,15
LA 15,SAVEAREA
ST 13,4(,15)
ST 15,8(,13)
LR 13,15
SAVE is a system macro instruction provided by IBM. It provides 2 things. At a minimum, it saves the registers in the save area provided by the calling program, and it provides for an identification. The listing looks like this -
SAVE (14,12),,*
+ B 12(0,15)
+ DC AL1(7)
+ DC CL7'PROGRAM'
+ STM 14,12,12(13)
+ B 12(0,15)
+ DC AL1(7)
+ DC CL7'PROGRAM'
+ STM 14,12,12(13)
The B instruction branches around the identification to the STM instruction to actually save the registers.
The LR 12,15 instruction copies the contents of register 15 to register 12. Now we can actually use the base register. This is not the only way. Some programmers prepare a base register like this -
BASR 12,0
USING *,12
The BASR (or BALR) instruction is normally used to call another program, BASR 14,15, for example. BASR stores the address of the next instruction in the first register. Then, if the second register is not 0, it uses the address in the register to define the next instruction to execute.
The next 4 instructions prepare a new save area for use. What we are actually doing is more complex than setting up register 13 to point to the new save area. Properly speaking, the save area is in two linked lists. The first list, at offset 4 in the save area allows your program to back track the save areas. By using the address at offset 8 a program such as the system dump program can go through the save areas.
There is one more wrinkle.
Starting with z/OS 1.7, the High Level Assembler, Binder, the Binder''s version of the linking loader, and program fetch were altered to allow the use of the BRAS and BRASL instructions to call an external reference or a symbol in a different CSECT. When doing this it is not necessary to load the address of the entry point into register 15, so modules prepared to get control from the BRAS or BRASL instruction might define addressability like this -
PROGRAM CSECT
BASR 15,0
USING *,12
SAVE (14,12),,*
LR 12,15
BASR 15,0
USING *,12
SAVE (14,12),,*
LR 12,15