HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


How to establish addressability

HLASM Language Reference
SC26-4940-06

To establish the addressability of a control section, element, or part (see Sections, elements, and parts), you must:
  • Specify a base address from which the assembler can compute displacements to the addresses within the control section, element, or part.
  • Assign the base registers to contain the base addresses.
  • Write the instructions that load the base registers with the base addresses.
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. By convention, register 15 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 *,12
The USING instruction indicates that register 12 can 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.

z/VM and z/OS
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 can 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 provides 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 can reference other parts in the same class using A-type and V-type address constants.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014