Technical information
New Addressing Modes and New Register Combinations in Data ALU Operations
Optimizing the Ported Code 15
For example, compare the instruction ADD on the DSP56800 to the instructions ADD, ADD.L, and
ADD.W on the DSP56800E. On the DSP56800, ADD operands can use the following addressing modes:
register, immediate, direct, and displacement relative to SP. Of course, there are restrictions regarding the
allowed register combinations. On the DSP56800E, these restrictions disappear, and new addressing
modes exist for ADD.W: indirect and indexed.
Code Example 19, taken from the function RXDEMOD (from the file rx_demod.asm), shows how the
ADD instruction was used on the DSP56800.
Code Example 19. ADD Usage on DSP56800
do #12,end_rx_demod ;Loop 12 times
...
move x:>CDP,a ;Load CDP
move x:>DPHASE,y0 ;Load DPHASE
add y0,a ;Update DPHASE value
move a1,x:>DPHASE ;Save DPHASE
...
end_rx_demod
; DSP56800 original code: 12*7 cycles / 7 words
The new pointer R4 could be used for addressing the variable DPHASE, which would allow the code
sequence to run faster. Also, the new accumulator C can be used to store the constant CDP. The rewritten
code is presented in Code Example 20.
Code Example 20. Optimized Code Using New Addressing Modes
move.l #DPHASE,r4 ;pointer of DPHASE kept in r4
move x:>CDP,d ;constant kept in d
...
do #12,end_rx_demod ;Loop 12 times
...
tfr d,a ;Load CDP from D
add.w x:(r4),a ;Update DPHASE value using indirect
; addressing
move.w a1,x:(r4) ;Save DPHASE using indirect addressing
...
end_rx_demod
; DSP56800E optimized code: 12*4 cycles / 7 words
The first version of the code sequence executed in 7 cycles; the modified version executed in only 4 cycles.
When this gain is multiplied by the number of loops (because the sequence is in a loop), the total
improvement is considerable. The code size was not modified with regard to the entire function
(RXDEMOD). Although the modified sequence is 4 words smaller, there are 2 move instructions added
outside this sequence to initialize the accumulator C and the pointer R4.
This method of optimization cannot be considered automatic because it depends on the availability of the
pointer register to keep the memory address of variables that are frequently accessed. In addition, it
requires a careful analysis of the entire function.
Another improvement is the elimination of the many restrictions regarding register combinations in data
ALU operations. Consider Code Example 21, which was also extracted from RXDEMOD.
Code Example 21. Restrictions Using MACR on DSP56800
do #12,end_rx_demod ;Loop 12 times
...
move y0,y1 ;transfer y0 to y1 to allow the
; following macr on DSP56800
macr b1,y1,a
...
end_rx_demod
; DSP56800 original code: 12*2 cycles / 2 words
The transfer from Y0 to Y1 is necessary on the DSP56800 because of restrictions regarding operands of
MACR (and similar instructions). On the DSP56800E, this restriction does not exist, and the code can be
written as in Code Example 22.
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...