Nested Hardware Do And Rep Loops - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

; Nesting Loops Recommended Technique
MOVE
#3,X:$0003
OUTER
;
(instructions)
DO
X0,INNER
ASL
A
MOVE
A,X:(R0)+
INNER
;
(instructions)
DECW
X:$0003
BGT
OUTER
It would also be possible to use a data ALU or AGU register if more speed is needed.
An exception to the preceding recommendation for nesting loops is for the unique case where the
innermost loop executes a single-word instruction. In this case it is possible to use a REP loop for the
innermost loop and a hardware DO loop for the outermost loop. This is demonstrated in the following
code:
; Nesting Loops Recommended Technique for Special Case of REP Loop Nested
; Within a Hardware DO Loop
INCW
A
DO
X0,LABEL
MOVE
B,Y1
;
(instructions)
REP
#4
ASL
A
;
(instructions)
MOVE
A,X:(R0)+
LABEL
The REP loop may not be interrupted, however, so this technique may not be useful for large loop counts
on the innermost loop if there are tight requirements for interrupt latency in an application. If this is the
case, then the first example with a software outer loop and an inner DO loop may be appropriate.
8.6.4.2

Nested Hardware DO and REP Loops

Nesting of hardware DO loops is permitted on the DSP56800 architecture. However, it is not
recommended that this technique be used for nesting loops within a program. Rather, it is recommended
that the hardware nesting of DO loops be used to provide more efficient interrupt processing, as described
in Section 8.6.4.1, "Recommendations."
Since the HWS is two locations deep, it is possible to nest one DO loop within another DO loop.
Furthermore, since the REP instruction does not use the HWS, it is possible to place a REP instruction
within these two nested DO loops. The following code shows the maximum nesting of hardware loops
allowed on the DSP56800 processor:
; Set up loop count for outer loop
; (software loop)
; DO loop is inner loop (hardware loop)
; Decrement outer loop count
; Branch to top of outer loop if not done
; DO loop is outer loop (interruptible)
; REP loop is inner loop (non-interruptible)
; (Must be a one-word instruction)
Software Techniques
Loops
8-23

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents