Structured Control - While

While - Loops through the commands specified while the <expression> is true.

The While statement has the following syntax:

WHILE[.size] expression DO[.extent]
code
ENDW

size - The value B, W, or L, specifying the size of the operand comparison. These values correspond to the Byte, Word, or Long word data size.
A size may not be specified when the expression consists of only a condition code.

expression - The expression tested. For a description of the expression syntax, see the Expression Syntax page.

extent - Optional value S or L, indicating the size of the forward branch to use (short or long).

code - The series of assembly commands executed continually while the expression is true.

One space should be used to separate each part of the statement.

===Notes===

If expression is false upon entry, the code instructions are never executed.

An expression of <T> is used to create an infinite loop.

WHILE <T> DO infinite loop
code
ENDW

The CCR's (condition code register) flags are set and tested by using this command before the code instructions are executed if at all.

EXAMPLE

WHILE.B D0 <LT> #5 DO.S
code
ENDW