Program Looping - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Program Controller
The software stack is also used for nesting hardware DO loops in software on the DSP56800 architecture.
On the DSP56800 architecture, the user must stack and unstack the LA and LC registers explicitly if DO
loops are nested. In this case, the software stack is typically used for this purpose, as demonstrated in
Section 8.6.4, "Nested Loops," on page 8-22. The hardware stack is used, however, for stacking the
address of the first instruction in the loop. Because this stack is implemented using locations in the X data
memory, there is no limit to the number of interrupts or jump-to subroutines or combinations of these that
can be accommodated by this stack.
Care must be taken to allocate enough space in the X data memory so that
stack operations do not overlap other areas of data used by the program.
Similarly, it may be desirable to locate the stack in on-chip memory to
avoid delays due to wait states or bus arbitration.
See Section 8.5, "Multiple Value Pushes," on page 8-19 and Section 8.8, "Parameters and Local
Variables," on page 8-28 for recommended techniques for using the software stack.
5.3

Program Looping

The DSP core supports looping on a single instruction (REP looping) and looping on a block of
instructions (DO looping). Hardware DO looping allows fast looping on a block of instructions and is
interruptible. Once the loop is set up with the DO instruction, there is no additional execution time to
perform the looping tasks. REP looping repeats a one-word instruction for the specified number of times
and can be efficiently nested within a hardware DO loop. It allows for excellent code density because
blocks of in-line code of a single instruction can be replaced with a one-word REP instruction followed by
the instruction to be repeated. The correct programming of loops is discussed in detail in Section 8.6,
"Loops," on page 8-20.
5.3.1
Repeat (REP) Looping
The REP instruction is a one-word instruction that performs single-instruction repeating on one-word
instructions. It repeats the execution of a single instruction for the amount of times specified either with a
6-bit unsigned value or with the 13 least significant bits of a DSP core register. When a repeat loop is
begun, the instruction to be repeated is only fetched once from the program memory; it is not fetched each
time the repeated instruction is executed. Repeat looping does not use any locations on the hardware stack.
It also has no effect on the LF or NL bits in the SR and OMR, respectively. Repeat looping cannot be used
on an instruction that accesses the program memory; it is necessary to use DO looping in this case.
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.
5-14
NOTE:
NOTE:
DSP56800 Family Manual

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents