dsp56800 Freescale Semiconductor, Inc, dsp56800 Datasheet - Page 131

no-image

dsp56800

Manufacturer Part Number
dsp56800
Description
16-bit Digital Signal Controllers
Manufacturer
Freescale Semiconductor, Inc
Datasheet
5.3.2
The DO instruction is a two-word instruction that performs hardware looping on a block of instructions. It
executes this block of instructions for the amount of times specified either with a 6-bit unsigned value or
using the 13 least significant bits of a DSC core register. DO looping is interruptible and uses one location
on the hardware stack for each DO loop. For cases where an immediate value larger than 63 is desired for
the loop count, it is possible to use the technique presented in Section 8.6.1, “Large Loops (Count Greater
Than 63),” on page 8-20.
The program controller register’s 13-bit loop count and 16-bit loop address register are used to implement
no-overhead hardware program loops. When a program loop is initiated with the execution of a DO
instruction, the following events occur:
A program loop begins execution after the DO instruction and continues until the program address fetched
equals the loop address register contents (the last address of program loop). The contents of the loop
counter are then tested for one. If the loop counter is not equal to one, the loop counter is decremented and
the top location in the DO Loop Stack is read (but not pulled) into the PC to return to the top of the loop. If
the loop counter is equal to one, the program loop is terminated by incrementing the PC, purging the stack
(pulling the top location and discarding the contents), and continuing with the instruction immediately
after the last instruction in the loop.
5.3.3
It is possible to nest up to two hardware DO loops and to nest a hardware REP loop within the two DO
loops. It is recommended when nesting loops, however, that hardware DO loops not be nested within code.
Instead, a software loop should be used for an outer loop instead of a second DO loop (see Section 8.6.4,
“Nested Loops,” on page 8-22).
Freescale Semiconductor
1. The LC and LA registers are loaded with values specified in the DO instruction.
2. The SR’s LF bit is set, and its old value is placed in the NL bit.
3. The address of the first instruction in the program loop is pushed onto the hardware stack.
DO Looping
Nested Hardware DO and REP Looping
REP loops are not interruptible since they are fetched only once. A DO
loop with a single instruction can be used in place of a REP instruction if
it is necessary to be able to interrupt while the loop is in progress.
For the case of REP looping with a register value, when the register
contains the value zero, then the instruction to be repeated is not executed
(as is desired in an application), and instruction flow continues with the
next sequential instruction. This is also true when an immediate value of
zero is specified.
For the case of DO looping with a register value, when the register contains
the value zero, then the loop code is repeated 2
number of bits in the LC register. If there is a possibility that a register
value may be less than or equal to zero, then the technique outlined in
Section 8.6.2, “Variable Count Loops,” on page 8-21 should be used. A
DO loop with an immediate value of zero is not allowed.
Program Controller
NOTE:
NOTE:
k
times, where k = 13 is the
Program Looping
5-15

Related parts for dsp56800