Главная Manuals High Level Assembler for z/OS & z/VM & z/VSE. Language Reference (Version 1 Release 6)
|
|
|
Definition mode occurs whenever a previously undefined symbol is encountered in
the name field of a statement, or in the operand field of an EXTRN or WXTRN
statement during open code processing. Symbols within a macro definition are
defined when the macro is expanded.
Lookahead mode is entered:
v When the assembler processes a conditional assembly instruction and encounters
an attribute reference (other than D' and O') to an ordinary symbol that is not
yet defined.
v When the assembler encounters a forward AGO or AIF branch in open code to a
sequence symbol that is not yet defined.
Lookahead is a sequential, statement-by-statement, forward scan over the source
text.
If the attribute reference is made in a macro, forward scan begins with the first
source statement following the outermost macro instruction. During lookahead the
assembler:
v Bypasses macro definition and generation
v Does not generate object text
v Does not perform open-code variable substitution
v Ignores AIF and AGO branch instructions
v Ignores the record following a REPRO statement
v Establishes interim data attributes for undefined symbols it encounters in
operand fields of instructions. The data attributes are replaced when a symbol is
encountered in definition mode.
Lookahead mode ends when the desired symbol or sequence symbol is found, or
when the END statement or end of file is reached. All statements read by
lookahead are saved on an internal file, and are fully processed when the
lookahead scan ends.
If a COPY instruction is encountered during lookahead, it is fully processed at that
time, the assembler copies the statements from the library, scans them, and saves
them on the lookahead file. When lookahead mode has ended any COPY
instructions saved to the lookahead file are ignored, as the statements from the
copy member have already been read and saved to the lookahead file.
If a variable symbol is used for the member name of a COPY that is expanded
during lookahead, the value of the variable symbol at the time the COPY is
expanded is used.
For purposes of attribute definition, a symbol is considered partially defined if it
depends in any way upon a symbol not yet defined. For example, if the symbol is
defined by a forward EQU that is not yet resolved, that symbol is assigned a type
attribute of U.
In this case it is possible that, by the end of the assembly, the type attribute has
changed to some other value.
Generating END statements
Because no variable symbol substitution is carried out during lookahead, consider
the following effects of using macro, AINSERT or open code substitution to
generate END statements that separate source modules assembled in one job step
Chapter 9. How to write conditional assembly instructions
341
(BATCH assembler option). If a symbol is undefined within a module, lookahead
might read statements past the point where the END statement is to be generated.
Lookahead stops when:
1. It finds the symbol
2. It finds an END statement
3. It reaches the end of the source input data set
In the first two cases, the assembler begins the next module at the statement after
lookahead stopped, which might be after the point where you wanted to generate
the END statement.
Lookahead restrictions
The assembler analyzes the statements it processes during lookahead, only to
establish attributes of symbols in their name fields.
Variable symbols are not replaced. Modifier expressions are evaluated only if all
symbols involved were defined prior to lookahead. Possible multiple or
inconsistent definition of the same symbol is not diagnosed during lookahead
because conditional assembly might eliminate one (or more) of the definitions.
Lookahead does not check undefined operation codes against library macro names.
If the name field contains an ordinary symbol and the operation code cannot be
matched with one in the current operation code table, then the ordinary symbol is
assigned the type attribute of M. If the operation code contains special characters
or is a variable symbol, a type attribute of U is assumed. This can be wrong if the
undefined operation code is later substituted with a known operation code or is
later defined by OPSYN. OPSYN statements are not processed; thus, labels are
treated in accordance with the operation code definitions in effect at the time of
entry to lookahead.
Sequence symbols
The conditional assembly instructions AGO and AIF in open code control the
sequence in which source statements are processed. Using these instructions it is
possible to branch back to a sequence symbol label and reuse previously processed
statements. Due to operating system restrictions, the primary input source can only
be read sequentially, and cannot be reread. Whenever a sequence symbol in the
name field is encountered in open code, the assembler must assume that all
subsequent statements might need to be processed more than once. The assembler
uses the lookahead file to save the statement containing the sequence symbol label
and all subsequent statements as they are read and processed. Any subsequent
AGO or AIF to a previously encountered sequence symbol is resolved to an offset
into the lookahead file and input continues from that point.
Open code
Conditional assembly instructions in open code let you:
v Select, during conditional assembly, statements or groups of statements from the
open code portion of a source module according to a predetermined set of
conditions. The assembler further processes the selected statements at assembly
time.
v Pass local variable information from open code through parameters into macro
definitions.
v Control the computation in and generation of macro definitions using global SET
symbols.
342
HLASM V1R6 Language Reference
v Substitute values into the model statements in the open code of a source module
and control the sequence of their generation.
All the conditional assembly elements and instructions can be specified in open
code.
The specifications for the conditional assembly language described in this chapter
also apply in open code. However, the following restrictions apply:
To Attributes In Open Code:
For ordinary symbols, only references to the type, length, scale, integer,
defined, and operation code attributes are allowed.
References to the number attribute have no meaning in open code, because
&SYSLIST is not allowed in open code, and symbolic parameters have no
meaning in open code.
To Conditional Assembly Expressions:
Table 55 shows the restrictions for different expression types.
Table 55. Restrictions on coding expressions in open code
Expression
Must not contain
v &SYSLIST
Arithmetic
v Symbolic parameters
(SETA)
v Any attribute references to symbolic parameters, or system variable
symbols with local scope
v System variables with local scope
Character
v Attribute references to system variables with local scope
(SETC)
v Symbolic parameters
v Arithmetic expressions with the items listed above
Logical
v Character expressions with the items listed above
(SETB)
Conditional assembly instructions
The remainder of this chapter describes, in detail, the syntax and rules for use of
each conditional assembler instruction. The following table lists the conditional
assembler instructions by type, and provides the page number where the
instruction is described in detail.
Chapter 9. How to write conditional assembly instructions
343
Table 56. Assembler instructions
Type of Instruction
Instruction
Page No.
Establishing SET symbols
GBLA
“GBLA,
GBLB, and
GBLC
instructions”
on page 345
GBLB
“GBLA,
GBLB, and
GBLC
instructions”
on page 345
GBLC
“GBLA,
GBLB, and
GBLC
instructions”
on page 345
LCLA
“LCLA,
LCLB, and
LCLC
instructions”
on page 347
LCLB
“LCLA,
LCLB, and
LCLC
instructions”
on page 347
LCLC
“LCLA,
LCLB, and
LCLC
instructions”
on page 347
SETA
“SETA
instruction”
on page 355
SETB
“SETB
instruction”
on page 369
SETC
“SETC
instruction”
on page 375
Branching
ACTR
“ACTR
instruction”
on page 400
AGO
“AGO
instruction”
on page 399
AIF
“AIF
instruction”
on page 396
ANOP
“ANOP
instruction”
on page 401
344
HLASM V1R6 Language Reference
Table 56. Assembler instructions (continued)
Type of Instruction
Instruction
Page No.
External Function Calling
SETAF
“SETAF
instruction”
on page 394
SETCF
“SETCF
instruction”
on page 395
Declaring SET symbols
You must declare a global SET symbol before you can use it. The assembler assigns
an initial value to a global SET symbol at its first point of declaration.
Local SET symbols need not be declared explicitly with LCLA, LCLB, or LCLC
statements. The assembler considers any undeclared variable symbol found in the
name field of a SETA, SETB, SETC, SETAF, or SETCF statement to be a local SET
symbol. It is given the initial value specified in the operand field. If the symbol in
the name field is subscripted, it is declared as a subscripted SET symbol.
GBLA, GBLB, and GBLC instructions
Use the GBLA, GBLB, and GBLC instructions to declare the global SETA, SETB,
and SETC symbols you need. The SETA, SETB, and SETC symbols are assigned the
initial values of 0, 0, and null character string.
,
▼
►►
GBLA
variable_symbol
►◄
sequence_symbol
GBLB
GBLC
sequence_symbol
Is a sequence symbol.
variable_symbol
Is a variable symbol, with or without the leading ampersand (&).
These instructions can be used anywhere in the body of a macro definition or in
the open code portion of a source module.
Any variable symbols declared in the operand field have a global scope. They can
be used as SET symbols anywhere after the pertinent GBLA, GBLB, or GBLC
instructions. However, they can be used only within those parts of a program in
which they have been declared as global SET symbols; that is, in any macro
definition and in open code.
The assembler assigns an initial value to the SET symbol only when it processes
the first GBLA, GBLB, or GBLC instruction in which the symbol appears. Later
GBLA, GBLB, or GBLC instructions do not reassign an initial value to the SET
symbol.
Chapter 9. How to write conditional assembly instructions
345
Multiple GBLx statements can declare the same variable symbol so long as only
one declaration for a given symbol is encountered during the expansion of a
macro.
The following rules apply to the global SET variable symbol:
v Within a macro definition, it must not be the same as any symbolic parameter
declared in the prototype statement.
v It must not be the same as any local variable symbol declared within the same
local scope.
v The same variable symbol must not be declared or used as two different types of
global SET symbol; for example, as a SETA or SETB symbol.
v Do not begin a global SET symbol with &SYS, because these characters are used
for system variable symbols.
v If the variable symbol is the same as the character value, the assembler considers
the variable symbol to be an implicitly defined local SETC symbol which is
given a null character string value. For example: &C6
SETC
’&C6’
,
assigns the value ’’ to &C6.
Subscripted global SET symbols
A global subscripted SET symbol is declared by the GBLA, GBLB, or GBLC
instruction.
,
▼
►►
GBLA
variable_symbol(dimension)
►◄
sequence_symbol
GBLB
GBLC
sequence_symbol
Is a sequence symbol.
variable_symbol
Is a variable symbol, with or without the leading ampersand (&).
dimension
Is the dimension of the array. It must be an unsigned, decimal, self-defining
term greater than zero.
Example:
GBLA
&GA(25),&GA1(15)
There is no limit on the maximum subscript allowed, except that each subscripted
variable is allocated storage, so the maximum subscript can be limited by the
amount of storage available. Also, the limit specified in the global declaration
(GBLx) can be exceeded. The dimension shows the number of SET variables
associated with the subscripted SET symbol. The assembler assigns an initial value
to every variable in the array thus declared.
Notes:
1. Global arrays are assigned initial values only by the first global declaration
processed, in which a global subscripted SET symbol appears.
346
HLASM V1R6 Language Reference
2. A subscripted global SET symbol can be used only if the declaration has a
subscript, which represents a dimension; an unsubscripted global SET symbol
can be used only if the declaration had no subscript, except for a number
attribute reference to the name of a dimensioned SET symbol.
Alternative format for GBLx statements
The assembler permits the alternative statement format for GBLx instructions:
Cont.
GBLA
&GLOBAL_SYMBOL_FOR_DC_GEN,
X
&LOOP_CONTRL_A,
X
&VALUE_PASSED_TO_FIDO,
X
&VALUE_RETURNED_FROM_FIDO
LCLA, LCLB, and LCLC instructions
Use the LCLA, LCLB, and LCLC instructions to declare the local SETA, SETB, and
SETC symbols you need. The SETA, SETB, and SETC symbols are assigned the
initial values of 0, 0, and null character string.
,
►►
LCLA
▼
variable_symbol
►◄
sequence_symbol
LCLB
LCLC
sequence_symbol
Is a sequence symbol.
variable_symbol
Is a variable symbol, with or without the leading ampersand (&).
These instructions can be used anywhere in the body of a macro definition or in
the open code portion of a source module.
Any variable symbols declared in the operand field have a local scope. They can
be used as SET symbols anywhere after the pertinent LCLA, LCLB, or LCLC
instructions, but only within the declared local scope. Multiple LCLx statements
can declare the same variable symbol so long as only one declaration for a given
symbol is encountered during the expansion of a macro.
The following rules apply to a local SET variable symbol:
v Within a macro definition, it must not be the same as any symbolic parameter
declared in the prototype statement.
v It must not be the same as any global variable symbol declared within the same
local scope.
v The same variable symbol must not be declared or used as two different types of
SET symbols; for example, as a SETA and a SETB symbol, within the same local
scope.
v Do not begin a local SET symbol with &SYS, because these characters are used
for system variable symbols.
Chapter 9. How to write conditional assembly instructions
347
Subscripted local SET symbols
A local subscripted SET symbol is declared by the LCLA, LCLB, or LCLC
instruction.
,
▼
►►
LCLA
variable_symbol(dimension)
►◄
sequence_symbol
LCLB
LCLC
sequence_symbol
Is a sequence symbol.
variable_symbol
Is a variable symbol, with or without the leading ampersand (&).
dimension
Is the dimension of the array. It must be an unsigned, decimal, self-defining
term greater than zero.
Example:
LCLB
&B(10)
There is no limit to SET symbol dimensioning other than storage availability. The
limit specified in the explicit (LCLx) or implicit (SETx) declaration can also be
exceeded by later SETx statements. The dimension shows the number of SET
variables associated with the subscripted SET symbol. The assembler assigns an
initial value to every variable in the array thus declared.
Subscripted local SET symbol: A subscripted local SET symbol can be used only
if the declaration has a subscript, which represents a dimension; an unsubscripted
local SET symbol can be used only if the declaration had no subscript, except for a
number attribute reference to the dimensioned SET symbol.
Alternative format for LCLx statements
The assembler permits an alternative statement format for LCLx instructions:
Cont.
LCLA
&LOCAL_SYMBOL_FOR_DC_GEN,
X
&COUNTER_FOR_INNER_LOOP,
X
&COUNTER_FOR_OUTER_LOOP,
X
&COUNTER_FOR_TRAILING_LOOP
Assigning values to SET symbols
You can assign values to SET symbols by using the SETA, SETB, SETC, SETAF, and
SETCF instructions (SETx). You can also use these instructions to implicitly define
local SET symbols. Local SET symbols need not be declared explicitly with LCLA,
LCLB, or LCLC statements. The assembler considers any undeclared variable
symbol found in the name field of a SETx statement to be a local SET symbol. It is
given the initial value specified in the operand field of SETA, SETB, and SETC
instructions, and the value returned from the external function specified in the
operand of SETAF and SETCF instructions. If the symbol in the name field is
subscripted, it is declared as a subscripted SET symbol.
348
HLASM V1R6 Language Reference
Spaces do not terminate the operand field when used in logical expressions and in
built-in functions. For more information, see “Logical (SETB) expressions” on page
372.
Introducing Built-In Functions
The assembler provides built-in functions for the SETA, SETB, and SETC
expressions.
Each function returns one value - an arithmetic value for SETA, a binary bit for
SETB, and a character string for SETC.
There are two different forms of invocation for the built-in functions:
v The logical-expression format encloses the function and operands in
parentheses. In the unary format, the function is followed by the one operand.
In the binary format, the function is placed between the two operands. For both
unary and binary formats, the function is separated from the operand or
operands by spaces.
Logical-expression unary format
►►
(built-in_function operand)
►◄
Logical-expression binary format
►►
(operand built-in_function operand)
►◄
(A OR B) and (&J SLL 2) are examples of binary logical-expression format
functions, and (NOT C) and (SIGNED &J) are examples of unary
logical-expression format functions.
v The function-invocation format has the function first, followed by one or more
operands in parentheses.
Function-invocation format
►► built-in_function(operand
)
►◄
▼
, operand
FIND(’abcde’,’d’) is an example of a function-invocation format. (The
equivalent logical-expression format is (’abcde’ FIND ’d’).)
Spaces are not allowed between the arguments of functions in
function-invocation format.
Chapter 9. How to write conditional assembly instructions
349
In either format, the operand is an expression of the type expected by the built-in
function. (The particular details of the number of operands and the operand type
are provided with the information for each built-in function.)
Conditional-assembly functions do not always behave like functions in traditional
high-level languages. The results of a function might not be automatically
converted to the type expected in the invoking expression, and nested invocations
might not produce expected results. In general, it is safest to invoke only one
conditional assembly function in a SET expression or AIF statement.
Some functions are available in one format, some are available in both. Table 57,
which provides a summary of all the built-in functions, shows the forms in which
a function is available.
Because some function names such as AND and OR are used both as arithmetic
operators and as logical connectives, their use might appear to be ambiguous. For
example, the function (1 AND 2) in an arithmetic expression is interpreted as the
logical AND of the two 32 bit SETA expressions 1 and 2, resulting in zero. In a
logical expression, the two nonzero operands are converted to 1 (meaning "true")
and the result is 1. Similarly, the function (1 XOR 2) in an arithmetic expression
has value 3, while in a logical expression it has value 0.
To avoid ambiguities, such function names are interpreted as arithmetic operators
in SETA statements, and as logical operators in SETB and AIF statements.
Table 57. Summary of Built-In Functions and Operators
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
A2B
Representation conversion
U
C
A
“Character-
valued
built-in
functions”
on page 381
A2C
Representation conversion
U
C
A
“Character-
valued
built-in
functions”
on page 381
A2D
Representation conversion
U
C
A
“Character-
valued
built-in
functions”
on page 381
A2X
Representation conversion
U
C
A
“Character-
valued
built-in
functions”
on page 381
AND
Logical
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
350
HLASM V1R6 Language Reference
Table 57. Summary of Built-In Functions and Operators
(continued)
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
AND
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
AND NOT
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
B2A
Representation conversion
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
B2C⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
B2D
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
B2X⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
BYTE
Representation conversion
U
U
C
A
“Character-
valued
built-in
functions”
on page 381
C2A
Representation conversion
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
C2B⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
C2D
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
Chapter 9. How to write conditional assembly instructions
351
Table 57. Summary of Built-In Functions and Operators
(continued)
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
C2X⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
D2A
Representation conversion
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
D2B
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
D2C
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
D2X
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
DCLEN
String manipulation
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
DCVAL
String manipulation
U
C
C
“Character-
valued
built-in
functions”
on page 381
DEQUOTE
String manipulation
U
C
C
“Character-
valued
built-in
functions”
on page 381
DOUBLE
String manipulation
U
U
C
C
“Character-
valued
built-in
functions”
on page 381
|
ESYM
String manipulation
U
C
C
“Character-
|
valued
|
built-in
|
functions”
|
on page 381
352
HLASM V1R6 Language Reference
Table 57. Summary of Built-In Functions and Operators
(continued)
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
FIND
String scanning
U
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
INDEX
String scanning
U
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
ISBIN
Validity checking
U
B
C
“Arithmetic
(SETA)
expressions”
on page
359
ISDEC
Validity checking
U
B
C
“Arithmetic
(SETA)
expressions”
on page
359
ISHEX
Validity checking
U
B
C
“Arithmetic
(SETA)
expressions”
on page
359
ISSYM
Validity checking
U
B
C
“Arithmetic
(SETA)
expressions”
on page
359
LOWER
String manipulation
U
U
C
C
“Character-
valued
built-in
functions”
on page 381
NOT
Logical
U
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
NOT
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
OR
Logical
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
Chapter 9. How to write conditional assembly instructions
353
Table 57. Summary of Built-In Functions and Operators
(continued)
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
OR
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
OR NOT
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
SIGNED
Representation conversion
U
U
C
A
“Character-
valued
built-in
functions”
on page 381
SLA
Shift
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
SLL
Shift
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
SRA
Shift
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
SRL
Shift
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
SYSATTRA
Information retrieval
U
C
C
“Character-
valued
built-in
functions”
on page 381
SYSATTRP
Information retrieval
U
C
C
“Character-
valued
built-in
functions”
on page 381
UPPER
String manipulation
U
U
C
C
“Character-
valued
built-in
functions”
on page 381
354
HLASM V1R6 Language Reference
Table 57. Summary of Built-In Functions and Operators
(continued)
Function
Type
L-E¹
F-I²
Result³
Operands³
Page
X2A
Representation conversion
U
A
C
“Arithmetic
(SETA)
expressions”
on page
359
X2B⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
X2C⁴
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
X2D
Representation conversion
U
C
C
“Character-
valued
built-in
functions”
on page 381
XOR
Logical
U
A
A
“Arithmetic
(SETA)
expressions”
on page
359
XOR
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
XOR NOT
Logical
U
B
B
“Logical
(SETB)
expressions”
on page
372
Notes:
1. If a U is in this column, the function is available in the “logical-expression” format.
2. If a U is in this column, the function is available in the “function-invocation” format.
3. Possible values in these columns are:
A
Arithmetic
B
Binary
C
Character
4. For these functions, the maximum length of the operand (and output) is the maximum
string length that the assembler supports, currently 4064.
SETA instruction
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.
Chapter 9. How to write conditional assembly instructions
355
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.
►► 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 47 on page 357 defines an arithmetic expression.
356
HLASM V1R6 Language Reference
┌───────────┐
│
│
│Arithmetic │
│Expression │
│
│
!─────┬─────┘
│
⌂ Can be any of
├────────────┬───────────┬────────────────────┬──────────┐
⌂
⌂
⌂
⌂
⌂
┌─────┴─────┐ ┌────┴────┐ ┌────┴──────────────┐ ┌───┴────┐
───┴────┐
│Arithmetic │ │ (Arith. │ │ Arithmetic-Valued │ │+Arith. │ │-Arith. │
│Term
│ │ Exp.)
│ │ Built-in Function │ │⌂ Exp. │ │⌂ Exp. │
!─────┬─────┘ !─────────┘ !───────────────────┘ !┼───────┘ !┼───────┘
│
!────┬─────┘
⌂ Can be any of
│
├─────────────┬─────────────┬─────────────┐
unary operators
⌂
⌂
⌂
⌂
┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐
│
│ │Predefined │ │ Self-
│ │
│
│ Variable
│ │Absolute
│ │ Defining
│ │ Attribute │
│ Symbol
│ │Ordinary
│ │ Term
│ │ Reference │
│
│ │Symbol
│ │
│ │
│
Operators Allowed
!───────────┘ !───────────┘ !───────────┘ !─────┬─────┘
│
Unary:
+ Positive
│
- Negative
│ Can
⌂ only be Binary: + Addition
┌─────┴─────┐
- Subtraction
│ Length
│
* Multiplication
│ Scale
│
/ Division
│ Integer
│
│ Count
│
Arith. Exp. = Arithmetic Expression
│ Number
│
│ Defined
│
!───────────┘
Figure 47. Defining arithmetic (SETA) expressions
Table 58 shows the variable symbols that are allowed as terms in an arithmetic
expression.
Table 58. Variable symbols allowed as terms in arithmetic expressions
Variable symbol
Restrictions
Example
Valid value
SETA
None
---
---
SETB
None
---
---
SETC
Value must evaluate to
123
123
an unsigned binary,
hexadecimal, or decimal
self-defining term
Symbolic parameters
Value must be a
&PARAM
X’A1’
self-defining term
&SUBLIST(3)
C’Z’
Corresponding operand
&SYSLIST(3)
24
&SYSLIST(n)
or sublist entry must be
a self-defining term
&SYSLIST(3,2)
B’101’
&SYSLIST(n,m)
Chapter 9. How to write conditional assembly instructions
357
Table 58. Variable symbols allowed as terms in arithmetic expressions (continued)
Variable symbol
Restrictions
Example
Valid value
None
---
---
&SYSDATC
&SYSM_HSEV
&SYSM_SEV
&SYSNDX
&SYSNEST
&SYSOPT_DBCS
&SYSOPT_RENT
&SYSOPT_XOBJECT
&SYSSTMT
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.
Subscripted SETA symbols
The SETA symbol in the name field can be subscripted. If the same SETA symbol
has not been previously declared in a GBLA or LCLA instruction with an allowable
dimension, or has not been implicitly declared in a SETA instruction as a scalar
(unsubscripted) variable symbol, then the symbol is implicitly declared as a local
SETA array variable.
The assembler assigns the value of the expression in the operand field to the
position in the declared array given by the value of the subscript. The subscript
expression must not be 0 or have a negative value.
358
HLASM V1R6 Language Reference
Arithmetic (SETA) expressions
Table 59 shows how arithmetic expressions can be used.
Table 59. Use of arithmetic expressions
Used in
Used as
Example
SETA instruction
Operand
&A1 SETA &A1+2
AIF or SETB instruction
Term in arithmetic AIF
(&A*10 GT 30).A
relation
Subscripted SET symbols
Subscript
&ASYM(&A+10-&C)
Substring notation
Subscript
’STRING’(&A*2,&A-1)
Sublist notation
Subscript
Given sublist (A,B,C,D)
named &PARAM,
if &A=1 then &PARAM(&A+1)=B
&SYSLIST
Subscript
&SYSLIST(&M+1,&N-2)
&SYSLIST(N’&SYSLIST)
SETC instruction
Character string in
operand
Given &C SETC
’5-10*&A’ ▌1▐
if &A=10 then
&C=5-10*10 ▌2▐
Given &D SETC
’5-10*&A’ ▌1▐
if &A=-10 then
&D=5-10*10▌3▐
Built-in functions
Operand
&VAR SETA
(NOT &OP1) &VAR SETA
BYTE(64)
When an arithmetic expression is used in the operand field of a SETC instruction
(see ▌1▐ in Table 59), the assembler assigns the character value representing the
arithmetic expression to the SETC symbol, after substituting values (see ▌2▐ in
Table 59) into any variable symbols. It does not evaluate the arithmetic expression.
The mathematical sign (+ or -) is not included in the substituted value of a variable
symbol (see ▌3▐ in Table 59), and any insignificant leading zeros are removed.
Here are the built-in functions for arithmetic (SETA) expressions:
AND
Format: Logical-expression
Operands: Arithmetic
Output: (aexpr1 AND aexpr2) provides an arithmetic result where each bit
position in the result is set to 1 if the corresponding bit positions in both
operands contain 1, otherwise, the result bit is set to 0.
Example
After the following statements &VAR contains the arithmetic value +2.
Name
Operation
Operand
&OP1
SETA
10
&OP2
SETA
2
&VAR
SETA
(&OP1 AND &OP2)
B2A
Chapter 9. How to write conditional assembly instructions
359
Format: Function-invocation
Operands: Character
Output: B2A(’bitstring’) converts a character string argument containing
’0’ and ’1’ characters to an arithmetic value.
v Fewer than 32 characters are padded internally on the left with ’0’
characters to a length of 32 characters.
v Error conditions are detected if the argument contains invalid characters,
or if the argument length exceeds 32 characters, generating the message
ASMA214E.
v Null argument strings return zero.
The result of the B2A function is the same as
&value SETA B’bitstring’
except that null strings are allowed by B2A but not by SETA.
Examples
B2A(’’)
has value 0
B2A(’0000000101’)
has value 5
B2A(’11111111111111111111111111111110’)
has value -2
C2A
Format: Function-invocation
Operands: Character
Output: C2A(’charstring’) converts a character string of zero to four
characters to a binary arithmetic value having the same bit pattern.
v Fewer than four characters are padded internally on the left with
EBCDIC null characters to a length of four characters.
v An error condition is detected if the argument length exceeds 4
characters, generating the message ASMA214E.
v Null argument strings return zero.
The result of C2A is the same as is obtained from
&value SETA C’charstring’
except that C2A gives a zero result for null strings, and does not pair
apostrophes or ampersands before conversion.
Example
C2A(’’)
has value 0
C2A(’+’)
has value 78
C2A(’1’)
has value 241
C2A(’0000’)
has value -252645136
D2A
Format: Function-invocation
Operands: Character
Output: D2A(’decstring’) converts a character string argument containing
an optional leading plus or minus sign followed by decimal digits to an
arithmetic value. Error conditions are detected if:
v The argument contains invalid characters.
v No digits are present following a sign.
v The argument length exceeds 11 characters.
v The resulting value is too large.
360
HLASM V1R6 Language Reference
|
|