Ax51 User's Guide

WHILE Function

The WHILE MPL function repeats a block until a specified condition is TRUE. The syntax for the WHILE function is:

%WHILE (expression) (balanced-text)

The WHILE function first evaluates the expression. If it is TRUE the balanced-text is expanded and the expression is reevaluated. If it is TRUE the balanced-text is expanded again and so on. This loop repeats until the expression is FALSE.

The balanced-text must modify the expression or the WHILE function never terminates. Additionally, the balanced-text may call the EXIT MPL function to terminate the WHILE function.

Source Text

%SET (count, 5)                %'initialize count to 5'
%WHILE (%count GT 0)
(
ADD   R5,R5
%SET (count, %count - 1)
)

Output Text

ADD   R5,R5
ADD   R5,R5
ADD   R5,R5
ADD   R5,R5
ADD   R5,R5