Hardware Loops
SC140 DSP Core Reference Manual
5-13
5.2.1.2 Loop Counter Registers (LCn)
The LCn registers are 32-bit read/write registers used to define the number of times each loop is to be
executed. LCn always holds a 32-bit signed value. This means that the largest number of loop iterations is
2
31
-1. The DOENn or DOENSHn instructions initialize the LCn register.
5.2.1.3 Status Register (SR) Loop Flag Bits
Certain status bits in the SR are associated with hardware loop initiation and execution. These bits are set
and cleared by special loop instructions such as DOENn as well as various loop conditions. They can also
be set and cleared by an explicit write to the SR. The bits are:
Loop Flag Bits
— Four loop flag bits (LF0, LF1, LF2, LF3) are defined in the SR, one for each
active loop. The bit is set when the loop is initiated by either the DOENn or the DOENSHn
instruction. It is cleared when the loop terminates.
Short Loop Flag Bit
— This bit (SLF) is set when the loop is initiated by the DOENSHn instruction.
It is cleared when the loop terminates. The short loop can only be used in the inner-most nesting
level.
5.2.2 Assembly Syntax for Hardware Loops
The assembly syntax for the loop definitions is as follows:
Loop Body
— The execution sets that are iterated during loop execution.
Long Loop
— A loop body that consists of three or more execution sets.
Short Loop
— A loop body that consists of one or two execution sets.
Start address (SA)
— The address of the first execution set in a loop body. Do not confuse this with
SA0, SA1, SA2, and SA3, which are register names used to hold SA values. The start address is
defined by the DOSETUPn label instruction and the LOOPSTARTn assembly directive. These two
redundant definitions of the start address must be consistent.
Last address (LA)
— The address of the last execution set in a loop body. LA is defined by the
LOOPENDn assembly directive. In the case of a loop with only one execution set, SA is also the last
address.
SA+1
— Address of the execution set following SA (similarly SA+2, and so on).
LA-2
— Address of the execution set that comes two execution sets before the execution set at LA
(similarly LA-1, and so on).
LPMARKA and LPMARKB
— Two marker bits in the prefix words that identify different looping
conditions. The LPMARK bits are set automatically by the assembler, not written by the user.