Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
ORG instruction HLASM Language Reference SC26-4940-06 |
|
The ORG instruction alters the setting of the location counter and thus controls the structure of the current control section. This redefines portions of a control section. If a control section has not been previously established, ORG initiates
an unnamed (private) control section.
>>-+--------+--ORG----------------------------------------------> '-symbol-' >--+--------------------------------------------+-------------->< '-expression-+-----------------------------+-' '-,-+-boundary--+---------+-+-' | '-,offset-' | '-,--offset-------------'
If boundary or offset are provided, then the resultant location counter is calculated by rounding the expression up to the next higher boundary and then adding the offset value. ORG emits no "fill" bytes for bytes skipped in any direction. In general, symbols used in expression need not have been previously defined. However, the relocatable component of expression (that is, the unpaired relocatable term) must have been previously defined in the same control section in which the ORG statement appears, or be equated to a previously defined value. A length attribute reference to the name of an ORG instruction is always invalid. Message ASMS042E is issued, and a default value of 1 is assigned. An ORG statement cannot be used to specify a location below the
beginning of the control section in which it appears. For example,
the following statement is not correct if it appears less than 500
bytes from the beginning of the current control section.
This is because the expression specified is negative, and sets the location counter to a value larger than the assembler can process. The location counter wraps around (the location counter is discussed in detail in Location counter). If you specify multiple location counters with the LOCTR instruction, the ORG instruction can alter only the location counter in use when the instruction appears. Thus, you cannot control the structure of the whole control section using ORG, but only the part that is controlled by the current location counter. An ORG statement cannot be used to change sections or LOCTR segments.
For example:
is invalid, because
the section containing the ORG statement (BB) is not the same as the
section in AA in which the ORG operand expression Y is defined.With the ORG statement, you can give two instructions the same
location counter values. In such a case, the second instruction does
not always eliminate the effects of the first instruction. Consider
the following example:
In this example, the value of B ('BETA') is destroyed by the relocation of ADDR during linkage editing. The following example shows some examples of ORG using the boundary
and offset operands:
Using Figure 1 as an example, to build a translate
table (for example, to convert EBCDIC character code into some other
internal code):
Both the assembled object code for the whole table filled with zeros, and the object code for the portions of the table you redefined, are printed in the program listings. However, the data defined later is loaded over the previously defined zeros and becomes part of your object program, instead of the zeros. That is, the ORG instruction can cause the location counter to
be set to any part of a control section, even the middle of an instruction,
into which you can assemble data. It can also cause the location
counter to be set to the next available location so that your program
can be assembled sequentially.
Figure 1. Building a translate table
Source Module │ Object Code ─────────────────────────────────────────────────────┼──────────────────────── │ FIRST START 0 │ . │ . │ 1 TABLE DC XL256'0' │ TABLE (in Hex) 2 ORG TABLE+0 │ +0 ┌────┐ ┌ DC C'0' 3 │ │ F0 │ │ DC C'1' │ │ F1 │ │ . │ │ . │ │ . │ │ . │ │ ORG TABLE+13 │ +13 │ . │ │ DC C'D' │ │ C4 │ │ DC C'E' │ │ C5 │ │ . │ │ . │ │ . │ │ . │ 4 ─┤ ORG TABLE+C'D' │ │ . │ │ DC AL1(13) │ +196 │ 13 │ │ DC AL1(14) │ │ 14 │ │ . │ │ . │ │ . │ │ . │ │ ORG TABLE+C'0' │ +240 │ . │ │ DC AL1(0) │ │ 00 │ │ DC AL1(1) │ │ 01 │ │ . │ │ │ └ . │ +255 └────┘ ORG │ 5 GOON DS 0H │ ∧ . │ TABLE+256 . │ TR INPUT,TABLE │ . │ . │ INPUT DS CL20 │ . │ . │ END │ |
Copyright IBM Corporation 1990, 2014
|