HLASM Language Reference
HLASM Language Reference HLASM Language Reference
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
- Page 34 and 35: Assembler Language Coding Conventio
- Page 36 and 37: Assembler Language Coding Conventio
- Page 38 and 39: Assembler Language Coding Conventio
- Page 40 and 41: Assembler Language Coding Conventio
- Page 42 and 43: Assembler Language Structure Condit
- Page 44 and 45: Assembler Language Structure Machin
- Page 46 and 47: Assembler Language Structure Condit
- Page 48 and 49: Terms, Literals, and Expressions Te
- Page 50 and 51: Terms, Literals, and Expressions -
- Page 52 and 53: Terms, Literals, and Expressions As
- Page 54 and 55: Terms, Literals, and Expressions Se
- Page 56 and 57: Terms, Literals, and Expressions Fo
- Page 58 and 59: Terms, Literals, and Expressions I
- Page 60 and 61: Terms, Literals, and Expressions Th
- Page 62 and 63: Terms, Literals, and Expressions 1.
- Page 64 and 65: Terms, Literals, and Expressions
- Page 66 and 67: Terms, Literals, and Expressions
- Page 68 and 69: Terms, Literals, and Expressions Th
- Page 70 and 71: | Chapter 3. Program Structures and
- Page 72 and 73: Source Module A source module is co
- Page 74 and 75: The CSECT instruction can be used a
- Page 76 and 77: | in linker control statements for
- Page 78 and 79: This is not only convenient, but it
- Page 80 and 81: | SECT_A CSECT , Define section SEC
- Page 82 and 83: | For executable sections, the loca
- Page 86 and 87: Addressing | Parts must always be r
- Page 88 and 89: Addressing Literal Pools ALPHA LR 3
- Page 90 and 91: Addressing If the symbol is the nam
- Page 92 and 93: Addressing External Symbol Dictiona
- Page 94 and 95: Addressing 74 HLASM V1R5 Language R
- Page 96 and 97: Part 2. Machine and Assembler Instr
- Page 98 and 99: General Instructions Chapter 4. Mac
- Page 100 and 101: Input/Output Operations For further
- Page 102 and 103: Branching with Extended Mnemonic Co
- Page 104 and 105: Symbolic Operation Codes variations
- Page 106 and 107: Operand Entries Registers You can s
- Page 108 and 109: Operand Entries “Program Structur
- Page 110 and 111: Operand Entries Format │ Coded or
- Page 112 and 113: Examples of Coded Machine Instructi
- Page 114 and 115: Examples of Coded Machine Instructi
- Page 116 and 117: Examples of Coded Machine Instructi
- Page 118 and 119: Examples of Coded Machine Instructi
- Page 120 and 121: Chapter 5. Assembler Instruction St
- Page 122 and 123: *PROCESS Statement *PROCESS Stateme
- Page 124 and 125: ACONTROL Instruction ►►──
- Page 126 and 127: ACONTROL Instruction FLAG(PAGE0) in
- Page 128 and 129: AINSERT Instruction character_strin
- Page 130 and 131: AMODE Instruction alias_string is t
- Page 132 and 133: CATTR Instruction Figure 25. AMODE/
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>