Previous Topic: ADD and COMPARE StatementsNext Topic: Exercise


BRANCH Statement

The following BRANCH statement uses the condition code to determine what action the program should take next.

BRANCH LT,MORE

In this program, the LT,MORE part of the BRANCH statement specifies that as long as the condition code is LT (A1 is less than A2), the program returns to the statement labeled MORE, which is the first line in the loop. Each time the program executes the loop, it moves the cursor down one line, types the message, increments A1 by one, and then compares A1 to A2 again.

The program continues to execute the loop until A1 is equal to A2. When A1 is equal to A2, the COMPARE statement sets a condition code of EQ. The branch statement only branches to the MORE label if A1 is less than A2, so the program proceeds to the STOP command and terminates.

EQ and LT are two of the seven condition codes used by ACL/E. For a more detailed discussion of condition codes, see the chapter Using Arithmetic and Logic.