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


Using SETA symbols

HLASM Language Reference
SC26-4940-06

The arithmetic value assigned to a SETA symbol is substituted for the SETA symbol when it is used in an arithmetic expression. If the SETA symbol is not used in an arithmetic expression, the arithmetic value is converted to a character string containing its absolute value, with leading zeros removed. If the value is 0, it is converted to a single 0.

Example:
          MACRO
 &NAME    MOVE            &TO,&FROM
          LCLA            &A,&B,&C,&D
 &A       SETA            10                  Statement 1
 &B       SETA            12                  Statement 2
 &C       SETA            &A-&B               Statement 3
 &D       SETA            &A+&C               Statement 4
 &NAME    ST              2,SAVEAREA
          L               2,&FROM&C           Statement 5
          ST              2,&TO&D             Statement 6
          L               2,SAVEAREA
          MEND
 -------------------------------------------------------------------
 HERE     MOVE            FIELDA,FIELDB
 -------------------------------------------------------------------
+HERE ST             2,SAVEAREA
+    L               2,FIELDB2
+    ST              2,FIELDA8
+    L               2,SAVEAREA

Statements 1 and 2 assign the arithmetic values +10 and +12 to the SETA symbols &A and &B. Therefore, statement 3 assigns the SETA symbol &C the arithmetic value -2. When &C is used in statement 5, the arithmetic value -2 is converted to the character 2. When &C is used in statement 4, however, the arithmetic value -2 is used. Therefore, &D is assigned the arithmetic value +8. When &D is used in statement 6, the arithmetic value +8 is converted to the character 8.

The following example shows how the value assigned to a SETA symbol can be changed in a macro definition.
          MACRO
 &NAME    MOVE            &TO,&FROM
          LCLA            &A
 &A       SETA            5                   Statement 1
 &NAME    ST              2,SAVEAREA
          L               2,&FROM&A           Statement 2
 &A       SETA            8                   Statement 3
          ST              2,&TO&A             Statement 4
          L               2,SAVEAREA
          MEND
 -------------------------------------------------------------------
 HERE     MOVE            FIELDA,FIELDB
 -------------------------------------------------------------------
+HERE ST             2,SAVEAREA
+    L               2,FIELDB5
+    ST              2,FIELDA8
+    L               2,SAVEAREA

Statement 1 assigns the arithmetic value +5 to SETA symbol &A. In statement 2, &A is converted to the character 5. Statement 3 assigns the arithmetic value +8 to &A. In statement 4, therefore, &A is converted to the character 8, instead of 5.

A SETA symbol can be used with a symbolic parameter to refer to an operand in an operand sublist. If a SETA symbol is used for this purpose, it must have been assigned a positive value.

Any expression that can be used in the operand field of a SETA instruction can be used to refer to an operand in an operand sublist. Sublists are described in Sublists in operands.

The following macro definition adds the last operand in an operand sublist to the first operand in an operand sublist and stores the result at the first operand. A sample macro instruction and generated statements follow the macro definition.
          MACRO
          ADDX            &NUMBER,&REG        Statement 1
          LCLA            &LAST
 &LAST    SETA            N'&NUMBER           Statement 2
          L               &REG,&NUMBER(1)
          A               &REG,&NUMBER(&LAST) Statement 3
          ST              &REG,&NUMBER(1)
          MEND
 -------------------------------------------------------------------
          ADDX            (A,B,C,D,E),3       Statement 4
 -------------------------------------------------------------------
+    L               3,A
+    A               3,E
+    ST              3,A

&NUMBER is the first symbolic parameter in the operand field of the prototype statement (statement 1). The corresponding characters (A,B,C,D,E) of the macro instruction (statement 4) are a sublist. Statement 2 assigns to &LAST the arithmetic value +5, which is equal to the number of operands in the sublist. Therefore, in statement 3, &NUMBER(&LAST) is replaced by the fifth operand of the sublist.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014