Comparison Of Outer Looping Techniques - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Software Techniques
; Hardware Nested Looping Example of the Maximum Depth Allowed
;
DO
#3,OLABEL
PUSH
LC
PUSH
LA
DO
X0,ILABEL
;
(instructions)
REP
Y0
ASL
A
;
(instructions)
ILABEL
POP
LA
POP
LC
NOP
NOP
NOP
OLABEL
The HWS's current depth can be determined by the NL and LF bits, as shown in Table 5-3, "Program
RAM Operating Modes," on page 5-11. From these bits it is possible to determine whether there are no
loops currently in progress, a single loop, or two nested loops. Refer to Section 5.1.9.8, "Reserved OMR
Bits—Bits 2, 7 and 9–14," on page 5-13 for the values of these bits in these different conditions.
For nested DO loops, it is required that there be at least three instructions after the POP of the LA and LC
registers and before the label of any outer loop. This requirement shows up in the preceding example as
three NOPs but can be fulfilled by any other instructions.
Further hardware nesting is possible by saving the contents of the HWS and later restoring the stack on
completion, as described in Section 8.13, "Multitasking and the Hardware Stack."
8.6.4.3

Comparison of Outer Looping Techniques

A comparison of the execution overhead and extra code size of software and hardware outer loops shows
that for loop nesting, it is just as efficient to nest in software (see Table 8-1). If a data ALU register or
AGU register is available for use as the loop count, each loop executes one cycle faster than nesting loops
in hardware. If there are no on-chip registers available for the loop counter, then the third technique can be
used that uses one of the first 64 locations of X data memory. This technique executes one cycle slower per
loop than nesting loops in hardware. Each of the software techniques also uses fewer instruction words.
Loop Technique
Hardware nested DO loops
Software using data ALU register
Software using AGU register
Software using memory location
It is recommended that the nesting of hardware DO loops not be used for implementing nested loops.
Instead, it is recommended that all outer loops in a nested looping scheme be implemented using software
looping techniques. Likewise, it is recommended that software looping techniques be used when a loop
contains a JSR and the called routine contains many instructions or contains a hardware DO loop.
8-24
; Beginning of outer loop
; Beginning of inner loop
; Skips ASL if y0 = 0
; End of inner loop
; three instructions required after POP
; three instructions required after POP
; three instructions required after POP
; End of outer loop
Table 8-1 Outer Loop Performance Comparison
Number of Icyc
to Set Up Loop
DSP56800 Family Manual
Additional
Number of Icyc
Executed
Each Loop
3
5
1
4
1
4
2
6
Total Number of
Instruction
Words
7
3
3
4

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents