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.
>>-+--------+--ORG----------------------------------------------> '-symbol-' >--+--------------------------------------------+-------------->< '-expression-+-----------------------------+-' '-,-+-boundary--+---------+-+-' | '-,offset-' | '-,--offset-------------'
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.
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.
The resultant location counter is calculated as follows:
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.
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
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.
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 │