Technical information

16 Porting and Optimizing DSP56800 Applications to DSP56800E
Code Example 22. Restrictions Removed Using MACR on DSP56800E
do #12,end_rx_demod ;Loop 12 times
...
macr b1,y0,a ;the register combination is
; allowed on DSP56800E
...
end_rx_demod
; DSP56800E optimized code: 12*1 cycles / 1 word
In terms of size, the gain is 1 word. In terms of speed, the gain is 1 cycle multiplied by the number of loops
(because the sequence is extracted from a loop).
Generally, wherever there are transfers between registers and these registers are used in the following data
ALU instructions, this method of optimization can be used automatically. However, be sure to check
whether the value stored in a register is used later in the program.
3.8 Nested Loops
The DSP56800E improves hardware support for DO looping. Unlike the DSP56800, which supports one
single hardware loop, the new core supports two nested hardware loops with no overhead.
To perform two nested loops on the DSP56800, the user must insert additional code that saves the LC and
LA registers before the inner loop and then restores them after the inner loop. See Code Example 23.
Code Example 23. Two Nested Loops on DSP56800
do #times_outer,END_OUTER_LOOP
...
lea (sp)+ ; 1 cycle / 1 word
move la,x:(sp)+ ; 1 cycle / 1 word
move lc,x:(sp) ; 1 cycle / 1 word
do #times_inner,END_INNER_LOOP
...
END_INNER_LOOP
pop lc ; 1 cycle / 1 word
pop la ; 1 cycle / 1 word
...
END_OUTER_LOOP
The DSP56800E core directly supports two nested hardware loops by automatically saving LA and LC
into the new LA2 and LC2 registers before the inner loop and restoring them afterward. See
Code Example 24.
Code Example 24. Two Nested Loops on DSP56800E
do #times_outer,END_OUTER_LOOP
...
do #times_inner,END_INNER_LOOP
...
END_INNER_LOOP
...
END_OUTER_LOOP
Code Example 23 contains five additional instructions compared to Code Example 24. All of these
instructions take 1 cycle to execute on the DSP56800. By eliminating these instructions that are
unnecessary on the DSP56800E, the code has a gain of 5 cycles that is multiplied by the number of times
the outer loop is executed.
This optimization method can be considered automatic. To quickly identify instances where this method
can be used, search for occurrences of DO and then examine whether any occurrence is preceded by
instructions that save LA and LC.
This optimization is especially suitable for DSP code, where nested loops are more frequently used.
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...