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


Evaluation of logical expressions

HLASM Language Reference
SC26-4940-06

The assembler evaluates logical expressions as follows:
  1. It evaluates each logical term, which is given a binary value of 0 or 1.
  2. If the logical term is an arithmetic or character relation, the assembler evaluates:
    1. The arithmetic or character expressions specified as values for comparison in these relations
    2. The arithmetic or character relation
    3. 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
  3. The assembler carries out logical operations from left to right. However,
    1. It carries out logical NOTs before logical ANDs, ORs, and XORs
    2. It carries out logical ANDs before logical ORs and XORs
    3. It carries out logical ORs before logical XORs
  4. 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.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014