
5-16
SC140 DSP Core Reference Manual
Program Control
5.2.6 Loop Instructions
Table 5-7 lists the loop instructions.
The instructions that activate the loop are either DOENn or DOENSHn. In nested loops, DOENn or
DOENSHn must be re-executed in order to re-activate the inner loops. In other words, the DOENn or
DOENSHn instruction for an inner loop must be contained in its corresponding outer loop. DOSETUPn is
only used to initialize SAn in long loops and need not be re-executed if the value of the SAn register is
unchanged. In short loop initialization, DOSETUPn is not needed at all. The instructions SKIPLS, CONT,
and BREAK (along with their variants) are optional, to be used only if needed.
The above instructions are assembled to mnemonics in the conventional way. They are also disassembled
normally. In addition, looping tags are encoded in the instruction prefix. When coding a hardware loop in
assembly, two loop-related assembly directives must be used to set LPMARKA and LPMARKB as
follows:
LOOPSTARTn
— Marks SA placed immediately before it.
LOOPENDn
— Marks LA placed immediately after it.
By definition, a loop body is enveloped by the LOOPSTART and LOOPEND directives.
In the disassembled code, the LOOPSTART directives are removed. The assembler has automatically
placed the LPMARK prefixes. The start address information is now encoded as an offset in the
DOSETUPn instruction for long loops, or in the LOOPMARK prefix words for short loops. The last
address is encoded in the LOOPMARK prefix words for long loops. The assembler normally places the
LOOPMARKB at LA-2. For special cases, such as a SKIPLS instruction to the last address, LPMARKA
Table 5-7. Loop Instructions
Instruction
Operation
DOSETUPn <label>
Initialize register SAn with <label> address.
Used only in long loops.
DOENn (reg or imm)
Activate loop n as a long loop. Performs the
following operations:
Initializes LCn
Sets LFn in the SR
DOENSHn (reg or imm)
Activate loop n as a short loop. Performs the
following operations:
Initializes LCn
Sets LFn and SLF in the SR
SKIPLS <label>
If LCn <= 0, jumps to <label>, clearing LFn.
CONT <label>
Within an active loop, if LC > 1, jumps to SAn and
decrements LCn. If LC <= 1 jumps to <label> and
clears the LCn register as well as LFn.
CONTD <label>
Provides a delayed version of the CONT
instruction.
BREAK <label>
Within an active loop, jumps to <label> and clears
LFn.