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


AIF instruction

HLASM Language Reference
SC26-4940-06

Use the AIF instruction to branch according to the results of a condition test. You can thus alter the sequence in which source program statements or macro definition statements are processed by the assembler.

The AIF instruction also provides loop control for conditional assembly processing, which lets you control the sequence of statements to be generated.

It also lets you check for error conditions and thus branch to the appropriate MNOTE instruction to issue an error message.
Read syntax diagramSkip visual syntax diagram
>>-+-----------------+--AIF------------------------------------->
   '-sequence_symbol-'        

>--(logical_expression)sequence_symbol-------------------------><

sequence_symbol
Is a sequence symbol
logical_expression
Is a logical expression (see Logical (SETB) expressions) the assembler evaluates during conditional assembly time to determine if it is true or false. If the expression is true (logical value=1), the statement named by the sequence symbol in the operand field is the next statement processed by the assembler. If the expression is false (logical value=0), the next sequential statement is processed by the assembler.
In the following example, the assembler branches to the label .OUT if &C = YES:
         AIF             ('&C' EQ 'YES').OUT
.ERROR   ANOP
         .
         .
         .
.OUT     ANOP

The sequence symbol in the operand field is a conditional assembly label that represents a statement number during conditional assembly processing. It is the number of the statement that is branched to if the logical expression preceding the sequence symbol is true.

The statement identified by the sequence symbol referred to in the AIF instruction can appear before or after the AIF instruction. However, the statement must appear within the local scope of the sequence symbol. Thus, the statement identified by the sequence symbol must appear:
  • In open code, if the corresponding AIF instruction appears in open code
  • In the same macro definition in which the corresponding AIF instruction appears.

You cannot branch from open code into a macro definition or between macro definitions, regardless of nested calls to other macro definitions.

The following macro definition generates the statements needed to move a fullword fixed-point number from one storage area to another. The statements are generated only if the type attribute of both storage areas is the letter F.
         MACRO
&N       MOVE            &T,&F
         AIF             (T'&T NE T'&F).END  Statement 1
         AIF             (T'&T NE 'F').END   Statement 2
&N       ST              2,SAVEAREA          Statement 3
         L               2,&F
         ST              2,&T
         L               2,SAVEAREA
.END     MEND                                Statement 4

The logical expression in the operand field of Statement 1 has the value true if the type attributes of the two macro instruction operands are not equal. If the type attributes are equal, the expression has the logical value false.

Therefore, if the type attributes are not equal, Statement 4 (the statement named by the sequence symbol .END) is the next statement processed by the assembler. If the type attributes are equal, Statement 2 (the next sequential statement) is processed.

The logical expression in the operand field of Statement 2 has the value true if the type attribute of the first macro instruction operand is not the letter F. If the type attribute is the letter F, the expression has the logical value false.

Therefore, if the type attribute is not the letter F, Statement 4 (the statement named by the sequence symbol .END) is the next statement processed by the assembler. If the type attribute is the letter F, Statement 3 (the next sequential statement) is processed.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014