HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


EQU instruction

HLASM Language Reference
SC26-4940-06

The EQU instruction assigns absolute or relocatable values to symbols. Use it to:
  • Assign single absolute values to symbols.
  • Assign the values of previously defined symbols or expressions to new symbols, thus letting you use different mnemonics for different purposes.
  • Compute expressions whose values are unknown at coding time or difficult to calculate. The value of the expressions is then assigned to a symbol.
  • Assign length and type attributes to symbols, either implicitly or explicitly.
  • Assign program type and assembler type values to symbols.

EQU also assigns attributes. It takes the value, relocation, and length attributes of the operand and assigns them to the name field symbol, and sets the integer and scale attributes to zero. The type attributes of an absolute expression is always 'U', and its length attribute is always 1 (unless the second and third operands are specified.

When there is a symbol naming a complex relocatable expression, or a complex relocatable expression is eventually "reduced" to an absolute or simply relocatable expression, the first symbol is used for attribute assignment.

The program type is always null, and the assembler type is always null, except when the appropriate operand is specified.
Read syntax diagramSkip visual syntax diagram
                                (1)                        
>>-symbol--EQU--expression_1--,------+--------------+--,-------->
                                     '-expression_2-'      

>--+--------------+--,--+--------------+--,--+--------------+--><
   '-expression_3-'     '-expression_4-'     '-expression_5-'   

Notes:
  1. Use commas as placeholders when there is an expression following
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
expression_1
Represents a value and attributes that the assembler assigns to the symbol in the name field. expression_1 can have any value allowed for an assembly expression: absolute (including negative), relocatable, or complexly relocatable. The assembler carries this value as a signed 4 byte (32 bit) number; all 4 bytes are printed in the program listings opposite the symbol. Implicitly, the relocation and length attributes are also assigned for certain types of expressions.

Any symbols used in expression_1 need not be previously defined. However, if any symbol is not previously defined, the value of expression_1 is not assigned to the symbol in the name field until assembly time and therefore cannot be used during conditional assembly (see Using conditional assembly values).

If expression_1 is a complexly relocatable expression, the whole expression, rather than its value, is assigned to the symbol. During the evaluation of any expression that includes a complexly relocatable symbol, that symbol is replaced by its own defining expression. Consider the following example, in which A1 and A2 are defined in one control section, and B1 and B2 in another:
X        EQU             A1+B1
Y        EQU             X-A2-B2

The first EQU statement assigns a complexly relocatable expression (A1+B1) to X. During the evaluation of the expression in the second EQU statement, X is replaced by its defining relocatable expression (A1+B1). The assembler evaluates the resulting expression (A1+B1-A2-B2) and assigns an absolute value to Y, because the relocatable terms in the expression are paired. The expression must not contain literals.

expression_2
Represents a value that the assembler assigns as a length attribute value to the symbol in the name field. It is optional, but, if specified, must be an absolute value in the range 0 to 65,535. This value overrides the normal length attribute value implicitly assigned from expression_1. For example:
A    DS    CL121          Define a print line buffer
ACC  Equ   A,1            Define first character, length 1
The symbol ACC has the same location value as A, but length attribute 1.
All symbols appearing in expression_2 must have been previously defined, and all expressions in expression_2 must be evaluatable when the EQU statement is processed. For example, the second operand in the statements defining the symbol X cannot be evaluated when the last statement has been processed, because the value of the symbol X is unknown until the symbol A has been defined.
Z    DS   XL(L'A)            Z    DS XL(A)
Y    DS   XL7                Y    DS XL7
X    EQU  Z,*-Z              X    EQU Z,*-Z
A    DS   XL5                A    EQU 5
If expression_2 is omitted, the assembler assigns a length attribute value to the symbol in the name field according to the length attribute value of the leftmost (or only) term of expression_1, as follows:
  1. If the leftmost term of expression_1 is a location counter reference (*), a self-defining term, or a symbol length attribute value reference, the length attribute is 1. This also applies if the leftmost term is a symbol that is equated to any of these values.
  2. If the leftmost term of expression_1 is a symbol that is used in the name field of a DC or DS instruction, the length attribute value is equal to the implicit or explicit length of the first (or only) constant specified in the DC or DS operand field.
  3. If the leftmost term is a symbol that is used in the name field of a machine instruction, the length attribute value is equal to the length of the assembled instruction.
  4. Symbols that name assembler instructions, except the DC, DS, CCW, CCW0, and CCW1 instructions, have a length attribute value of 1. Symbols that name a CCW, CCW0, or CCW1 instruction have a length attribute value of 8.
  5. The length attribute value described in cases 2, 3, and 4 above is the assembly-time value of the attribute.

For more information about the length attribute value, see Symbol length attribute reference.

For example:
X   DS    CL80            X has length attribute 80
Y   EQU   X,40            Y has length attribute 40
expression_3
Represents a value that the assembler assigns as a type attribute value to the symbol in the name field. It is optional, but, if specified, it must be an absolute value in the range 0 to 255.

All symbols appearing in expression_3 must have been previously defined, and all expressions in expression_3 must be evaluatable when the EQU statement is processed.

If expression_3 is omitted, the assembler assigns a type attribute value of U to the symbol, which means the symbol in the name field has an undefined (or unknown or unassigned) type attribute. See the general discussion about data attributes in Data attributes, and Type attribute (T').

For example:
A    DS    D             A has type attribute D
B    EQU   A,,C'X'       B has type attribute X
expression_4
Represents a value (any absolute expression) that the assembler assigns as a program type value to the symbol in the name field. It is optional. It can be specified as a decimal, character, hex, or binary self-defining term and is stored as a 4 byte (32 bit) number; all 4 bytes are printed in the program listings opposite the symbol. The value is not used in any way by the assembler, and can be queried by using the SYSATTRP built-in function.

All symbols appearing in expression_4 must have been previously defined, and all expressions in expression_4 must be evaluatable when the EQU statement is processed.

If expression_4 is omitted, the assembler assigns a null to the program type, and querying the value using the SYSATTRP built-in function returns a null value.

expression_5
Represents 2 to 4 characters that the assembler assigns as an assembler type value to the symbol in the name field. It is optional. It is stored as a 4 byte string; all 4 bytes are printed in the program listings opposite the symbol. The value is used by the assembler when type-checking has been activated, and can be queried by using the SYSATTRA built-in function.
Valid values for this operand are:
AR       Register - Access
CR       Register - Control
CR32     Register - Control 32 bit
CR64     Register - Control 64 bit
FPR      Register - Floating-Point
GR       Register - General
GR32     Register - General 32 bit
GR64     Register - General 64 bit

If expression_5 is omitted, the assembler assigns a null value to the assembler type, and querying the value using the SYSATTRA built-in function returns a null value.

The EQU instruction can be used anywhere in a source module after the ICTL instruction. Note, however, that the EQU instruction initiates an unnamed control section (private code) if it is specified before the first control section.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014