You can use symbolic addresses in machine instructions and certain assembler instructions. This is much easier than explicitly coding the addresses in the form required by the hardware. Symbolic addresses you code in the instruction operands are implicit addresses, and addresses in which you specify the base-displacement or intermediate form are explicit addresses.
The assembler converts your implicit addresses into the explicit addresses required for the assembled object code of the machine instruction. However, for base-displacement operands, you must first establish addressability, as described below.
Base Address Definition: The term base address is used throughout this manual to mean the location counter value within a control section, element, or part from which the assembler can compute displacements to locations, or addresses. The base address need not always be the storage address of a control section, element, or part when it is loaded into storage at execution time.
To establish the addressability of a control section, element, or part (see Sections, elements, and parts), you must:
The following example shows the base address at MYPROG, that is assigned by register 12. Register 12 is loaded with the value in register 15, which by convention usually contains the storage address (set by the operating system) of the control section (CSECT) when the program is loaded into storage at execution time.
MYPROG CSECT The base address
USING MYPROG,12 Assign the base register
LR 12,15 Load the base address
Similarly, you can use a BASR or similar instruction to put the address of the following instruction into register 12.
BASR 12,0
USING *,12The USING instruction indicates that register 12 may be used as a base register containing that address.
During assembly, the implicit addresses you code are converted into their explicit base-displacement form; then, they are assembled into the object code of the machine instructions in which they have been coded.
During execution, the base address is loaded into the base register.
If you specify multiple classes, you must provide addressability for each element. For example, suppose you define two classes that must reference positions in the other:
MYPROG CSECT ,
CLASS_A CATTR RMODE(24) Define class CLASS_A
BASR 12,0 Local base register
USING *,12 Addressability for this element
- - -
L 1,Addr_B Address of BDATA in CLASS_B
USING BDATA,1
- - -
ADATA DS F Data in CLASS_A
Addr_B DC A(BDATA)
- - -
CLASS_B CATTR RMODE(31) Define class CLASS_B
BASR 11,0 Local base register
USING *,11 Addressability for this element
- - -
L 2,Addr_A Address of ADATA in CLASS_A
USING ADATA,2
- - -
BDATA DS D Data in CLASS_B
Addr_A DC A(ADATA)
A class specifying the "deferred load" (DEFLOAD) attribute on its defining CATTR statement cannot be referenced from other classes using A-type or V-type address constants. However, A-type and V-type address constants may be used within a deferred-load class to refer to locations within that class or within any default_load (LOAD) class.
The loading service for deferred-load classes will provide the origin address of the deferred-load segment containing the classes. You can then use Q-type address constants in other classes to calculate the addresses of items in the loaded classes. For example:
MYPROG CSECT ,
CLASS_A CATTR RMODE(31)
BASR 12,0 Set base register
USING *,12 Addressability for this element
- - -
* Address of CLASS_B segment assumed to be returned in register 8
- - -
A 8,BDATAOff Add offset of BDATA in CLASS_B
USING BDATA,8
- - -
BDATAOff DC Q(BDATA) Offset of BDATA
- - -
CLASS_B CATTR DEFLOAD,RMODE(ANY) Define deferred-load class
- - -
BDATA DS F Data in deferred-load class
Parts must always be referenced from LOAD classes using Q-type address constants using the techniques shown in this example, whether or not they reside in deferred load classes. This is because parts are subject to reordering during binding. As noted above, parts may reference other parts in the same class using A-type and V-type address constants.
[ Top of Page | Previous Page | Next Page | Contents | Index ]