HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

Addressing | The System/390® and z/Architecture architectures have two ways of resolving addresses in your program, depending on the machine instruction type: base-displacement, where the address is computed by adding the displacement to the contents of a base register. | relative-immediate, where the address is computed by adding 2 × the signed immediate operand field to the instruction's address (refer to “RI Format” on page 91 and “RSI Format” on page 95). Addressing within Source Modules: Establishing Addressability 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. How to Establish Addressability To establish the addressability of a control section, element, or part (see “Sections, Elements, and Parts” on page 52), 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, 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, USING ,12 The USING instruction indicates that register 12 may be used as a base register containing that address. 64 HLASM V1R5 Language Reference

Addressing 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, 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, 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. | 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, 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 Chapter 3. Program Structures and Addressing 65

Addressing<br />

| The System/390® and z/Architecture architectures have two ways of resolving<br />

addresses in your program, depending on the machine instruction type:<br />

base-displacement, where the address is computed by adding the<br />

displacement to the contents of a base register.<br />

| relative-immediate, where the address is computed by adding 2 × the signed<br />

immediate operand field to the instruction's address (refer to “RI Format” on<br />

page 91 and “RSI Format” on page 95).<br />

Addressing within Source Modules: Establishing Addressability<br />

You can use symbolic addresses in machine instructions and certain assembler<br />

instructions. This is much easier than explicitly coding the addresses in the form<br />

required by the hardware. Symbolic addresses you code in the instruction<br />

operands are implicit addresses, and addresses in which you specify the<br />

base-displacement or intermediate form are explicit addresses.<br />

The assembler converts your implicit addresses into the explicit addresses required<br />

for the assembled object code of the machine instruction. However, for<br />

base-displacement operands, you must first establish addressability, as described<br />

below.<br />

Base Address Definition: The term base address is used throughout this manual<br />

to mean the location counter value within a control section, element, or part from<br />

which the assembler can compute displacements to locations, or addresses. The<br />

base address need not always be the storage address of a control section,<br />

element, or part when it is loaded into storage at execution time.<br />

How to Establish Addressability<br />

To establish the addressability of a control section, element, or part (see “Sections,<br />

Elements, and Parts” on page 52), you must:<br />

Specify a base address from which the assembler can compute displacements<br />

to the addresses within the control section, element, or part.<br />

Assign the base registers to contain the base addresses.<br />

Write the instructions that load the base registers with the base addresses.<br />

The following example shows the base address at MYPROG, that is assigned by<br />

register 12. Register 12 is loaded with the value in register 15, which by convention<br />

usually contains the storage address (set by the operating system) of the control<br />

section (CSECT) when the program is loaded into storage at execution time.<br />

MYPROG CSECT The base address<br />

USING MYPROG,12<br />

Assign the base register<br />

LR 12,15 Load the base address<br />

Similarly, you can use a BASR or similar instruction to put the address of the<br />

following instruction into register 12.<br />

BASR 12,<br />

USING ,12<br />

The USING instruction indicates that register 12 may be used as a base register<br />

containing that address.<br />

64 <strong>HLASM</strong> V1R5 <strong>Language</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!