ORG instruction
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.
- symbol
- Is one of the following:
- An ordinary symbol
- A variable symbol that has been assigned a character string with a value that is valid for an ordinary symbol
- A sequence symbol
If symbol denotes an ordinary symbol, the ordinary symbol is defined with the value that the location counter had before the ORG statement is processed.
- expression
- Is a relocatable expression, the value of which is used to set the location counter. If expression is omitted, the location counter is set to the next available location for the current control section.
- boundary
- Is an absolute expression that must be a number that is a power of 2 with a range from 2
(halfword) to 4096 (page). If boundary exceeds the SECTALGN value, message
ASMA500W is issued. This message is
not issued if the section being processed is a DSECT.
boundary must be a predefined absolute expression whose value is known at the time the ORG statement is processed.
If the boundary operand is greater than 16, the GOFF option must be specified in addition to the SECTALGN option.
- offset
- Any absolute expression
The resultant location counter is calculated as follows:
- Evaluate expression.
- If boundary is specified, round the result to the next multiple of boundary.
- If offset is specified, adjust the result by adding offset.
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 ASMA042E is issued, and a default value of 1 is assigned.
ORG *-500
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.
AA CSECT
X DS D
Y DS F
BB CSECT
ORG Y
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.ADDR DC A(ADDR)
ORG *-4
B DC C'BETA'
In this example, the value of B ('BETA')
is destroyed
by the relocation of ADDR
during linkage editing.
origin csect
ds 235x Define 235 bytes
org origin,,3 Move location counter back to start + 3
org *,8 Align on 8 byte boundary
org *,8,-2 Align to 8 byte boundary -2 bytes
translate dc cl256' ' Define aligned translate table
org translate+c'a'
dc c'ABCDEFGHI'
org translate+c'j'
dc c'JKLMNOPQR'
org translate+c's'
dc c'STUVWXYZ'
org translate+c'A'
dc c'ABCDEFGHI'
org translate+c'J'
dc c'JKLMNOPQR'
org translate+c'S'
dc c'STUVWXYZ'
org ,
end
- Define the table (see 1 in Figure 1) as being filled with zeros.
- Use the ORG instruction to alter the location counter so that its counter value indicates a specific location (see 2 in Figure 1) within the table.
- Redefine the data (see 3 in Figure 1) to be assembled into that location.
- After repeating the first three steps (see 4 in Figure 1) until your translate table is complete, use an ORG instruction with a null operand field to alter the location counter. The counter value then indicates the next available location (see 5 in Figure 1) in the current control section (after the end of the translate table).
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.
