HLASM Language Reference
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.
Read syntax diagramSkip visual syntax diagram
>>-+--------+--ORG---------------------------------------------->
   '-symbol-'        

>--+--------------------------------------------+--------------><
   '-expression-+-----------------------------+-'   
                '-,-+-boundary--+---------+-+-'     
                    |           '-,offset-' |       
                    '-,--offset-------------'       

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 ASMA500E is issued. This message is not issued if the section being processed is a Reference Control Section (DSECT, DXD, or COM).

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

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.
         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.

An ORG statement cannot be used to change sections or LOCTR segments. For example:
         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.
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:
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.

The following example shows some examples of ORG using the boundary and offset operands:
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
Using Figure 1 as an example, to build a translate table (for example, to convert EBCDIC character code into some other internal code):
  1. Define the table (see  1  in Figure 1) as being filled with zeros.
  2. 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.
  3. Redefine the data (see  3  in Figure 1) to be assembled into that location.
  4. 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.

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 ModuleObject 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                               │

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014