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 | Parts must always be referenced 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. | Base Register Instructions The USING and DROP assembler instructions enable you to use expressions representing implicit addresses as operands of machine instruction statements, leaving the assignment of base registers and the calculation of displacements to the assembler. In order to use symbols in implicit addresses in the operand field of machine instruction statements, you must: Code a USING instruction to assign one or more base registers to a base address or sequence of base addresses Code machine instructions to load each base register with the base address Having the assembler determine base registers and displacements relieves you of the need to separate each address into an explicit displacement value and an explicit base register value. This feature of the assembler eliminates a likely source of programming errors, thus reducing the time required to write and test programs. You use the USING and DROP instructions to take advantage of this feature. For information about how to use these instructions, see “USING Instruction” on page 218 and “DROP Instruction” on page 172. Qualified Addressing Qualified addressing lets you use the same symbol to refer to data in different storage locations. Qualified symbols are simply ordinary symbols prefixed by a symbol qualifier and a period. A symbol qualifier is used to specify which base register the assembler should use when converting an implicit address into its explicit base-displacement form. Before you use a symbol qualifier, you must have previously defined it in the name entry of a labeled USING instruction. For information about labeled USING instructions, see “USING Instruction” on page 218. When defined, you can use a symbol qualifier to qualify any symbol that names a storage location within the range of the labeled USING. Qualified symbols may be used anywhere a relocatable term may be used. The following examples show the use of qualified symbols. SOURCE and TARGET are both symbol qualifiers previously defined in two labeled USING instructions. X and Y are both symbols that name storage locations within the range of both labeled USING instructions. MVC TARGET.X,SOURCE.X MVC TARGET.Y+5(3),SOURCE.Y+5 XC TARGET.X+1(L'X-1),TARGET.X+1 LA 2,SOURCE.Y 66 HLASM V1R5 Language Reference

Addressing Dependent Addressing Dependent addressing lets you minimize the number of base registers required to refer to data by making greater use of established addressability. For example, you may want to describe the format of a table of data defined in your source module with a dummy control section (see “Dummy Control Sections” on page 56). To refer to the data in the table using the symbols defined in the dummy section, you need to establish the addressability of the dummy section. To do this you must: Code a USING instruction to assign one or more base registers to a base address Code machine instructions to load each base register with the base address However, dependent addressing offers an alternative means of establishing addressability of the dummy section. When you have established addressability of the control section in which the table is defined, you can establish addressability of the dummy section by simply coding a USING statement which specifies the name of the dummy section and the address of the table. When you subsequently refer to the symbols in the dummy section, the assembler makes use of the already established addressability of the control section when converting the symbolic addresses into their base-displacement form. | For example, suppose addressability has been established for a control section | containing a data structure that is mapped by a dummy control section: | DATAMAP DSECT , DSECT describing data structure | FIELD1 DS F | FIELD2 DS CL32 | FIELD3 DS CL24 | - - - | CODE CSECT , Program code | BASR 12, Set base register | USING ,12 Provide addressability | - - - | USING DATAMAP,REALDATA Map DSECT onto REALDATA | L 2,FIELD1 Register 12 is base register | LA 3,FIELD3 Address of DATA3 | - - - | REALDATA DS F Data mapped by DATAMAP | DATA1 DC F'32' | DATA2 DC CL32'Actual Data' | DATA3 DC CL24'Additional Data' Relative Addressing Relative addressing is the technique of addressing instructions and data areas by designating their location in relation to the location counter or to some symbolic location. This type of addressing is always in bytes—never in bits, words, or instructions. Thus, the expression +4 specifies an address that is 4 bytes greater than the current value of the location counter. In the sequence of instructions in the following example, the location of the CR machine instruction can be expressed in two ways, ALPHA+2, or BETA-4, because all the machine instructions in the example are for 2-byte instructions. Chapter 3. Program Structures and Addressing 67

Addressing<br />

Dependent Addressing<br />

Dependent addressing lets you minimize the number of base registers required to<br />

refer to data by making greater use of established addressability. For example, you<br />

may want to describe the format of a table of data defined in your source module<br />

with a dummy control section (see “Dummy Control Sections” on page 56). To<br />

refer to the data in the table using the symbols defined in the dummy section, you<br />

need to establish the addressability of the dummy section. To do this you must:<br />

Code a USING instruction to assign one or more base registers to a base<br />

address<br />

Code machine instructions to load each base register with the base address<br />

However, dependent addressing offers an alternative means of establishing<br />

addressability of the dummy section.<br />

When you have established addressability of the control section in which the table<br />

is defined, you can establish addressability of the dummy section by simply coding<br />

a USING statement which specifies the name of the dummy section and the<br />

address of the table. When you subsequently refer to the symbols in the dummy<br />

section, the assembler makes use of the already established addressability of the<br />

control section when converting the symbolic addresses into their<br />

base-displacement form.<br />

| For example, suppose addressability has been established for a control section<br />

| containing a data structure that is mapped by a dummy control section:<br />

| DATAMAP DSECT , DSECT describing data structure<br />

| FIELD1 DS F<br />

| FIELD2 DS CL32<br />

| FIELD3 DS CL24<br />

| - - -<br />

| CODE CSECT , Program code<br />

| BASR 12, Set base register<br />

| USING ,12 Provide addressability<br />

| - - -<br />

| USING DATAMAP,REALDATA Map DSECT onto REALDATA<br />

| L 2,FIELD1 Register 12 is base register<br />

| LA 3,FIELD3 Address of DATA3<br />

| - - -<br />

| REALDATA DS F Data mapped by DATAMAP<br />

| DATA1 DC F'32'<br />

| DATA2 DC CL32'Actual Data'<br />

| DATA3 DC CL24'Additional Data'<br />

Relative Addressing<br />

Relative addressing is the technique of addressing instructions and data areas by<br />

designating their location in relation to the location counter or to some symbolic<br />

location. This type of addressing is always in bytes—never in bits, words, or<br />

instructions. Thus, the expression +4 specifies an address that is 4 bytes greater<br />

than the current value of the location counter. In the sequence of instructions in<br />

the following example, the location of the CR machine instruction can be expressed<br />

in two ways, ALPHA+2, or BETA-4, because all the machine instructions in the<br />

example are for 2-byte instructions.<br />

Chapter 3. Program Structures and Addressing 67

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

Saved successfully!

Ooh no, something went wrong!