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


Symbol length attribute reference

HLASM Language Reference
SC26-4940-06

The length attribute of a symbol can be used as a term. Reference to the attribute is made by coding L' followed by the symbol, as in:
L'BETA
The length attribute of BETA is substituted for the term. When you specify a symbol length attribute reference, you obtain the length of the instruction or data named by a symbol. You can use this reference as a term in instruction operands to:
  • Specify assembler-determined storage area lengths
  • Cause the assembler to compute length specifications for you
  • Build expressions to be evaluated by the assembler
The symbol length attribute reference must be specified according to the following rules:
  • The format must be L' immediately followed by a valid symbol (L'SYMBOL), an expression (L'SYMBOL+SYMBOL2-SYMBOL7), or the location counter reference (L'*). If the operand is an expression, the length attribute of its leftmost term is used.
  • Symbols must be defined in the same source module in which the symbol length attribute reference is specified.
  • The symbol length attribute reference can be used in the operand of any instruction that requires an absolute term. However, it cannot be used in the form L'* in any instruction or expression that requires a previously defined symbol.

The value of the length attribute is normally the length in bytes of the storage area required by an instruction, constant, or field represented by a symbol. The assembler stores the value of the length attribute in the symbol table along with the address value assigned to the symbol.

When the assembler encounters a symbol length attribute reference, it substitutes the value of the attribute from the symbol table entry for the symbol specified.

The assembler assigns the length attribute values to symbols in the name field of instructions as follows:
  • For machine instructions (see  1  in Table 1), it assigns 2, 4, or 6, depending on the format of the instruction.
  • For the DC and DS instructions (see  2  in Table 1), it assigns either the implicitly or explicitly specified length of the first or only operand. The length attribute is not affected by a duplication factor.
  • For the EQU instruction, it assigns the length attribute value of the first or only term (see  3  in Table 1) of the first expression in the first operand, unless a specific length attribute is supplied in a second operand.
    Note the length attribute values of the following terms in an EQU instruction:
    • Self-defining terms (see  4  in Table 1)
    • Location counter reference (see  5  in Table 1)
    • L'* (see  6  in Table 1)

For assembler instructions such as DC, DS, and EQU, the length attribute of the location counter reference (L'* — see  6  in Table 1) is equal to 1. For machine instructions, the length attribute of the location counter reference (L'* — see  7  in Table 1) is equal to the length attribute of the instruction in which the L'* appears.

Table 1. Assignment of length attribute values to symbols in name fields
Source Module Length Attribute Reference Value of Symbol Length Attribute At Assembly Time
MACHA     MVC  TO,FROM
MACHB     L    3,ADCON
MACHC     LR   3,4

TO        DS   CL80
FROM      DS   CL240
ADCON     DC   A(OTHER)
CHAR      DC   C'YUKON'
DUPL      DC   3F'200'

RELOC1    EQU  TO          3 
RELOC2    EQU  TO+80       3 
RELOC3    EQU  TO,44       3 
ABSOL1    EQU  FROM-TO     3 
ABSOL2    EQU  ABSOL1      3 

SDT1      EQU  102         3 
SDT2      EQU  X'FF'+A-B   3 
SDT3      EQU  C'YUK'

ASTERISK  EQU  *+10        3 

LOCTREF   EQU  L'*         3 
LENGTH1   DC   A(L'*)


LENGTH2   MVC  TO(L'*),FROM
LENGTH3   MVC  TO(L'TO-20),FROM
L'MACHA
L'MACHB
L'MACHC

L'TO
L'FROM
L'ADCON
L'CHAR
L'DUPL

L'RELOC1
L'RELOC2
L'RELOC3
L'ABSOL1
L'ABSOL2

L'SDT1
L'SDT2
L'SDT3

L'ASTERISK

L'LOCTREF
L'*
L'LENGTH1

L'*
L'TO
6     1 
4     1 
2     1 

80    2 
240   2 
4     2 
5     2 
4     2 

80
80
44
240
240

1     4 
1     4 
1     4 

1     5 

1     6 
1     6 
4

6     7 
80
Note: Instructions that contain length attribute references L'SDT1, L'SDT2, L'SDT3, L'ASTERISK, and L'LOCTREF as shown in this figure might generate ASMA019W.
The following example shows how to use the length attribute to move a character constant into either the high-order or low-order end of a storage field.
A1       DS              CL8
B2       DC              CL2'AB'
HIORD    MVC             A1(L'B2),B2
LOORD    MVC             A1+L'A1-L'B2(L'B2),B2

A1 names a storage field eight bytes in length and is assigned a length attribute of 8. B2 names a character constant 2 bytes in length and is assigned a length attribute of 2. The statement named HIORD moves the contents of B2 into the first 2 bytes of A1. The term L'B2 in parentheses provides the length specification required by the instruction.

The statement named LOORD moves the contents of B2 into the rightmost 2 bytes of A1. The combination of terms A1+L'A1-L'B2 adds the length of A1 to the beginning address of A1, and subtracts the length of B2 from this value. The result is the address of the seventh byte in field A1. The constant represented by B2 is moved into A1 starting at this address. L'B2 in parentheses provides the length specification in both instructions.

For ease in following the preceding example, the length attributes of A1 and B2 are specified explicitly in the DS and DC statements that define them. However, keep in mind that the L'symbol term makes coding such as this possible in situations where lengths are unknown. For example:
C3       DC              C'This is too long a string to be worth counting'
STRING   MVC             BUF(L'C3),C3

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014