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


SETA instruction

HLASM Language Reference
SC26-4940-06

The SETA instruction assigns an arithmetic value to a SETA symbol. You can specify a single value or an arithmetic expression from which the assembler computes the value to assign.

You can change the values assigned to an arithmetic or SETA symbol. This lets you use SETA symbols as counters, indexes, or for other repeated computations that require varying values.
Read syntax diagramSkip visual syntax diagram
>>-variable_symbol--SETA--expression---------------------------><

variable_symbol
Is a variable symbol.

A global variable symbol in the name field must have been previously declared as a SETA symbol in a GBLA instruction. Local SETA symbols need not be declared in an LCLA instruction. The assembler considers any undeclared variable symbol found in the name field of a SETA instruction as a local SET symbol. The variable symbol is assigned a type attribute value of N.

expression
Is an arithmetic expression evaluated as a signed 32 bit arithmetic value that is assigned to the SETA symbol in the name field. The minimum and maximum allowable values of the expression are -231 and +231-1.
Figure 1 defines an arithmetic expression.
Figure 1. Defining arithmetic (SETA) expressions
┌───────────┐
│           │
│Arithmetic │
│Expression │
│           │
└─────┬─────┘
      │
      V Can be any of

      ├────────────┬───────────┬────────────────────┬──────────┐
      V            V           V                    V          V
┌─────┴─────┐ ┌────┴────┐ ┌────┴──────────────┐ ┌───┴────┐  ───┴────┐
│Arithmetic │ │ (Arith. │ │ Arithmetic-Valued │ │+Arith. │ │-Arith. │
│Term       │ │  Exp.)  │ │ Built-in Function │ │  Exp. │ │  Exp. │
└─────┬─────┘ └─────────┘ └───────────────────┘ └┼───────┘ └┼───────┘
      │                                          └────┬─────┘
      V Can be any of                                 │
      ├─────────────┬─────────────┬─────────────┐    unary operators
      V             V             V             V
┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐
│           │ │Predefined │ │ Self-     │ │           │
│ Variable  │ │Absolute   │ │ Defining  │ │ Attribute │
│ Symbol    │ │Ordinary   │ │ Term      │ │ Reference │
│           │ │Symbol     │ │           │ │           │     Operators Allowed
└───────────┘ └───────────┘ └───────────┘ └─────┬─────┘
                                                │           Unary:  + Positive
                                                │                   - Negative
                                                │ Can
                                                V only be   Binary: + Addition
                                          ┌─────┴─────┐             - Subtraction
                                          │ Length    │             * Multiplication
                                          │ Scale     │             / Division
                                          │ Integer   │
                                          │ Count     │
Arith. Exp. = Arithmetic Expression       │ Number    │
                                          │ Defined   │
                                          └───────────┘

Table 1 shows the variable symbols that are allowed as terms in an arithmetic expression.

Table 1. Variable symbols allowed as terms in arithmetic expressions
Variable symbol Restrictions Example Valid value
SETA None --- ---
SETB None --- ---
SETC Value must evaluate to an unsigned binary, hexadecimal, or decimal self-defining term 123 123
Symbolic parameters Value must be a self-defining term
&PARAM
 
&SUBLIST(3)
X'A1'
 
C'Z'

&SYSLIST(n)
 
&SYSLIST(n,m)

Corresponding operand or sublist entry must be a self-defining term
&SYSLIST(3)
 
&SYSLIST(3,2)
24
 
B'101'

&SYSDATC
&SYSM_HSEV
&SYSM_SEV
&SYSNDX
&SYSNEST
&SYSOPT_DBCS
&SYSOPT_RENT
&SYSOPT_XOBJECT
&SYSSTMT

None --- ---
The following example shows a SETA statement with a valid self-defining term in its operand field:
&ASYM1   SETA  C'D'           &ASYM1 has value 196 (C'D')
The second statement in the following example is valid because in the two positions in the SETA operand where a term is required (either side of the + sign), the assembler finds a valid self-defining term:
&CSYM2   SETC  'C''A'''       &CSYM2 has value C'A'
&ASYM3   SETA  &CSYM2+&CSYM2  &ASYM3 has value 386 (C'A' + C'A')
If the variable symbol is the same as the character value, the assembler considers the variable symbol to be an implicitly defined local SETA symbol, which is given a value of zero. For example:
&ASYM2   SETA  &ASYM2
&ASYM2 has a value 0.
A SET statement is not rescanned by the assembler to see if substitutions might affect the originally determined syntax. The original syntax of the self-defining term must be correct. Therefore the assembler does not construct a self-defining term in a SETA statement. The third statement of the next example shows this:
&CSYM3   SETC  '3'            &CSYM has value 3 (C'3')
&ASYM3   SETA  &CSYM3         &ASYM has value 3
&ASYM4   SETA  C'&ASYM3'      Invalid self-defining term
In this example C'&ASYM3' is not a valid term.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014