Technical information

Immediate Operands
Optimizing the Ported Code 11
Code Example 7. Using Address Registers to Store Addresses
do #12,END_RX_BPF
move x:>BPF_PTR,r3 ; 2 cycles, 2 words
... use and modify r3
END_RX_BPF
; DSP56800 original code: 12*2 cycles / 2 words
move.w x:>BPF_PTR,r4 ; 2 cycles, 2 words
do #12,END_RX_BPF
tfra r4,r3 ; 1 cycle, 1 word
... use and modify r3
END_RX_BPF
; DSP56800E optimized code: 2+12*1 cycles / 2+1 words
The optimization methods presented save 74 cycles per symbol out of an initial average of 4278.5 cycles
per symbol, resulting in an improvement of 1.7 percent.
3.3 Immediate Operands
This optimization method consists of using ADD, SUB, and CMP between a register and an immediate
value directly instead of first loading the immediate into a temporary register.
On the DSP56800, there are two ways to use ADD, SUB, or CMP between an immediate value and a
register. The first one is to load the immediate into a register and then perform the operation between two
registers. The second one is to use the immediate directly. Both variants have the same speed, but the
second takes 1 less word to be encoded. The variants are presented in Code Example 8.
Code Example 8. Two Ways of Performing CMP with Immediate on DSP56800
move #$125,x0 ; 4 cycles, 2 words
cmp y0,x0 ; 2 cycles, 1 word
; DSP56800 original code: 6 cycles / 3 words
cmp #$125,x0 ; 6 cycles, 2 words
; DSP56800 code optimized for size: 6 cycles / 2 words
On the DSP56800E, both variants are possible, but the second variant takes not only 1 fewer word but also
1 fewer cycle. See Code Example 9.
Code Example 9. Two Ways of Performing CMP with Immediate on DSP56800E
move.w #$125,x0 ; 2 cycles, 2 words
cmp.w y0,x0 ; 1 cycle, 1 word
; DSP56800E original code: 3 cycles / 3 words
cmp.w #$125,x0 ; 2 cycles, 2 words
; DSP56800E code optimized for size and speed: 2 cycles / 2 words
This method of optimization can often be used automatically. However, programmers must be careful to
observe whether the immediate value that is loaded into the register is used somewhere else. If it is, this
method cannot be used.
This method was performed on more than half the functions that were optimized because in the main code
example, most all comparisons with immediates were performed through intermediate registers.
3.4 AGU Arithmetic
Compared to the DSP56800, the arithmetic capabilities of the AGU improved considerably on the
DSP56800E. Pointer arithmetic can be done directly in the AGU, whereas on the DSP56800 the arithmetic
operations must be performed in the data ALU and the result must be transferred in a pointer. These new
DSP56800E facilities provide capabilities to improve both speed and code density.
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...