Loops

The various types of loop are described below.

Code

Loop type

Aborting condition

@131

While Loop

while equal

@132

While Loop

while not equal

@133

While Loop

while greater

@134

While Loop

while greater or equal

@135

While Loop

while less

@136

While Loop

while less or equal

@141

Repeat Loop

repeat until equal

@142

Repeat Loop

repeat until not equal

@143

Repeat Loop

repeat until greater

@144

Repeat Loop

repeat until greater or equal

@145

Repeat Loop

repeat until less

@146

Repeat Loop

repeat until less or equal

@151

For-To Loop

 

@161

For-DownTo Loop

 

Loops can be nested.

While loops

Command

@13<n>

where 1<= n <= 6

Parameter 1

R<m>

Comparison value

Parameter 2

K or R<k>

Comparison value

Parameter 3

K

Jump destination for the case that the condition is not met

A while loop is executed for as long as the condition is satisfied. The test is made at the beginning of the loop. If the condition is not or no longer met, a jump to the specified line takes place (parameter 3).

At the end of the While loop an unconditional jump (@100) must be programmed. The target of this jump is the line number of the while loop.

The loop’s exit condition is specified with <n>.

Sample 1:

N100 R6=4
N200 @131 R6 K4 K600 (K600 is the target of the jump, when the condition is no longer satisfied)
N210 ...
N220 @100 K-200

N600 ...

N5000 M30

The loop (lines 200 to 220) is repeated for as long as R6 = 4. Once the condition is no longer satisfied, execution jumps to line 600.

Repeat loops

Command

@14<n>

where 1<= n <= 6

Parameter 1

R<m>

Comparison value

Parameter 2

K or R<k>

Comparison value

Parameter 3

K

Jump destination at the start of the loop

In a repeat loop, the interrogation takes place at the end of the loop. This means that the loop is executed at least once. The loop is only ended, to continue with the rest of the program, when the condition is satisfied.

Sample 2:

N200 ...
N210 ...

N300 @141 R6 K25 K200

The loop is repeated until R6 = 25. The second constant in line 300 gives the jump target (the start of the loop).

For-To loops

Command

@151 <variable> <value> <constant>

A for-to loop is a counting loop that is executed until the variable equals the value. The test is made at the beginning of the loop. If that condition is satisfied, execution jumps to the line specified by the constant.

The variable must be incremented (@620) at the end of the loop, and there must be an unconditional jump to the start of the loop.

Sample 3:

N190 R6=0
N200 @151 R6 K20 K400
N210 ...
N290 @620 R6 (increment R6)
N300 @100 K-200

For-Downto Loops

Command

@161 <variable> <value> <constant>

A for-downto loop is a counting loop. The behaviour is similar to that of a for-to loop. The difference is merely that the variable is decremented (@621) by 1 at the end of the loop.