HLASM Toolkit Feature User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


IF macros with Boolean operators

HLASM Toolkit Feature User's Guide
GC26-8710-10

All the options described in the preceding sections can be combined into longer logical expressions using Boolean operators AND, OR, ANDIF, and ORIF. (These are reserved keywords and cannot be used as operands of instructions.) A NOT operator has not been implemented since a complement exists for each of the alphabetic condition mnemonics described previously.

All logical expressions are scanned from left to right. When the AND and OR connectors are used, the code generated is such that as soon as the expression can be verified as either true or false the appropriate branch to process either the code for F1 or the code for F2 is taken without executing the remaining tests. Statements that are continued onto more than one line must have a non-space character in the continuation indicator column (normally column 72) of all statements except the last. Continued statements must have a non-space character in the continuation column (normally column 16)

This example:
        IF  (10),OR,                                                 X
            (AR,R2,R3,NZ),AND,                                       X
            (ICM,R1,M3,B2(D2),4)  THEN
          Code for F1
        ELSE
          Code for F2
        ENDIF
produces:
        IF  (10),OR,                                                  X
              (AR,R2,R3,NZ),AND,                                      X
              (ICM,R1,M3,B2(D2),4)  THEN
          BC    10,#@LB2
          AR    R2,R3
          BC    15-7,#@LB1
               ICM R1,M3,B2(D2)
          BC    15-4,#@LB1
#@LB2     DC    0H
          Code for F1
        ELSE
          BC    15,#@LB3
#@LB1     DC    0H
          Code for F2
        ENDIF
#@LB3     DC    0H

If the condition code mask setting is 10 upon entering the IF code, the program immediately branches to the F1 code. If it is not 10, and if the next condition code setting is such that the desired relation is not true, the branch is made around the third test to the F2 code. This is done since the AND condition cannot be met if the second relation is false.

The ANDIF and ORIF are used to give a parenthetical grouping capability to the logical expressions. The use of either of these two as connectors of logical groupings, the use of AND or OR indicates a closing parenthesis on the preceding group and an opening parenthesis on the one following. Therefore, if the previous example is modified by replacing the AND by an ANDIF, this means that either the first or second condition must be true as well as the third one in order to execute F1.

An example of this:
        IF (10),OR,                                                   X
           (AR,R2,R3,NZ),ANDIF,                                       X
           (ICM,R1,M3,B2(D2),4)  THEN
          Code for F1
        ELSE
          Code for F2
        ENDIF
produces:
        IF (10),OR,                                                   X
              (AR,R2,R3,NZ),ANDIF,                                    X
              (ICM,R1,M3,B2(D2),4)  THEN
          BC    10,#@LB2
          AR    R2,R3
          BC    15-7,#@LB1
#@LB2     DC    0H
              ICM R1,M3,B2(D2)
          BC    15-4,#@LB1
          Code for F1
        ELSE
          BC    15,#@LB4
#@LB1     DC    0H
          Code for F2
        ENDIF
#@LB4     DC    0H

For a better illustration of the effect of the ANDIF and ORIF usage, the examples which follow use capital letters to indicate the conditions that are tested.

If you write
  A OR B AND C
the implied grouping is A OR (B AND C).

If you write
  A OR B ANDIF C
the grouping is (A OR B) AND C.

The ORIF may be similarly used:
  A AND B ORIF C OR D
is interpreted as (A AND B) OR (C OR D).

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014