loop - Start loop statement

loop - Start loop statement

Calling Format

loop    src

Operands

Name Description
src Integer register

Overview

This is used together with endloop. It repeatedly executes the instructions between loop and endloop according to the contents of the integer register specified by src.
The integer register comprises a loop count, an initial value for the loop-counter register, and an amount by which to increment the loop-counter register, stored in the count, init, and step components, respectively. (Set the integer register to the defi instruction or uniform. For details, see "defi – Define integer constants" and "bind_symbol ( symbol_name , start_index [, end_index] )".)
The loop-counter register (aL) is initialized when the loop instruction is executed. When control reaches endloop, the loop-counter register is incremented by the increment amount and control returns to the loop instruction.
After this process repeats one time more than the loop count in the integer register, the loop instruction ends and execution picks up from the next instruction after endloop.

Up to four loop instructions can be nested.
If the loop-counter register were incremented by a negative number its value could become less than 0, but in such cases it will be set to 255 due to underflow.
Behavior is undefined if a floating-point constant register is offset by a value of 96 or greater.

There must be at least one instruction between loop and endloop.

Operation

for ( int i = 0, aL = src.init ; i < src.count+1 ; i++, aL += src.step )
{
    ...
}

Code Example

defi i0, 10, 0, 1

loop i0
    add r0, r0, c0[ aL ]    // Add the total of c0, c1, ... , c10 to r0
endloop

Revision History

2011/12/20
Initial version.

CONFIDENTIAL