Technical information

20 Porting and Optimizing DSP56800 Applications to DSP56800E
Code Example 28. Optimized Ported Code on DSP56800E
move.w #0,y1 ; 1 cycle, 1 word
...
tst.w a ; 1 cycle, 1 word
...
jgt APOS ; 5/4 cycles, 2 words
move.w #$0100,y1 ; cycles, 2 words
APOS
...
move.w #0,x0 ; 1 cycle, 1 word
tst b ; 1 cycle, 1 word
jgt BPOS ; 5/4 cycles, 2 words
move.w #$0100,x0 ; 2 cycles, 2 words
BPOS
...
move.w x0,b1
...
eor.w y1,b ; 1 cycle, 1 word
...
tst b ; 1 cycle, 1 word
jeq TANOK ; 5/4 cycles, 2 words
neg a ; 1 cycle, 1 word
TANOK
; DSP56800E optimized ported code: 23-25 cycles / 13 words
In the code that was written from scratch, a better sequence was obtained. See Code Example 29. Note that
this sequence does not use new DSP56800E features.
Code Example 29. DSP56800E Code Written from Scratch
move.w a,y1 ; 1 cycle, 1 word
...
move.w b,c1 ; 1 cycle, 1 word
...
eor.w c1,y1 ; 1 cycle, 1 word
bge SAME_SIGN ; 5/4 cycles, 1 word
neg a ; l cycle, 1 word
SAME_SIGN
; DSP56800E written from scratch code: 8 cycles / 5 words
Another difference between code written from scratch and optimized code is that the latter uses conditional
transfers wherever possible instead of using conditional jumps, that take a higher number of cycles to
execute. Code Example 30 presents this.
Code Example 30. Using Conditional Transfers Instead of Conditional Jumps
move.w #$0400,x0 ; 2 cycles, 2 words
sub b,a ; 1 cycle, 1 word
jge POS ; 5/4 cycles, 2words
move.w #$fc00,x0 ; 2 cycles, 2 words
POS
... use x0
; DSP56800 optimized ported code: 8/9 cycles / 7 words
move.w #$0400,b ; 2 cycles, 2 words
...
move.w #$fc00,y0 ; 2 cycles, 2 words
sub a,d ; 1 cycle, 1 word
tgt y0,b ; 1 cycle, 1 word
... use b1
; DSP56800E written from scratch code: 6 cycles / 6 words
Note that, unlike the other instructions, Jcc and Bcc take approximately the same number of cycles on both
DSP56800 and DSP56800E. It is recommended to replace them with Tcc wherever possible.
5 Pipeline Effects on DSP56800E
DSP56800E has a different pipeline structure, with more pipeline stages as compared to DSP56800. This
explains the different pipeline effects of these two DSPs. Both DSPs have pipeline dependencies which
can be met (especially AGU dependencies). DSP56800E introduced a few pipeline dependencies that did
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...