The assembler evaluates logical expressions as follows:
- It evaluates each logical term, which is given a binary value
of 0 or 1.
- If the logical term is an arithmetic or character relation, the
assembler evaluates:
- The arithmetic or character expressions specified as values for
comparison in these relations
- The arithmetic or character relation
- The logical term, which is the result of the relation. If the
relation is true, the logical term it represents is given a value
of 1; if the relation is false, the term is given a value of 0.
The
two comparands in a character relation are compared, character by
character, according to binary (EBCDIC) representation of the characters.
If two comparands in a relation have character values of unequal
length, the assembler always takes the shorter character value to
be less.
Character comparisons are recognized by the presence
of an opening apostrophe in the first operand. For example, if a character
comparison involves a character function and a character constant,
the constant must be written first, as in
AIF ('A' eq UPPER('a')).Okay
- The assembler carries out logical operations from left to right.
However,
- It carries out logical NOTs before logical ANDs, ORs, and XORs
- It carries out logical ANDs before logical ORs and XORs
- It carries out logical ORs before logical XORs
- In parenthesized logical expressions, the assembler evaluates
the innermost expressions first, and then considers them as logical
terms in the next outer level of expressions. It continues this process
until it evaluates the outermost expression.