Technical information
26 Porting and Optimizing DSP56800 Applications to DSP56800E
Code Example 42. DSP56800 Original Code
rx_next_task
lea (sp)+
move x:>RxQ_ptr,r3 ; Restore the RxQ pointer
incw x:RxQ_ptr ; Increment the RxQ_ptr.
move x:(r3),x0 ; Get the address of next task
move x0,x:(sp)+ ; Push the address of task to be
move sr,x:(sp) ; performed onto the stack
rts ; Perform task
; DSP56800 original code
This code is functional on the DSP56800E platform within the 64K program memory boundary. The
problem occurs when the program memory is extended over 64K. The upper bits of a program address are
stored in the SR register. The previous code will not work on the DSP56800E platform. It should be
replaced with the specialized instruction available only on DSP56800E: JMP (n). This is presented in
Code Example 43.
Code Example 43. DSP56800E Modified Code
rx_next_task
moveu.w x:>RxQ_ptr,r3
inc.w x:RxQ_ptr
moveu.w x:(r3),n
jmp (n) ; 3 cycles less
; DSP56800E ported code
At this stage, the code is still not ready to run on the extended program memory because the data width
stored into the R3 register is 16 bits. The Code Example 44 presents all the corrections required by this
program memory extension.
Code Example 44. DSP56800E Code That Allow Program Memory Access Beyond 64K
move.l x:>RxQ_ptr,r3 ;Pointer stored in memory has 32b
adda #2,r3,n ;Long arithmetic: added 2 words
move.l n,x:RxQ_ptr ;Storing back the pointer
move.l x:(r3),n ;Reading the address for jump
jmp (n) ;Performing the jump
; DSP56800E ported code
A summary of the extended program memory size for this application is presented in Table 10.
The initial code was the code modified to support data memory extended addresses, presented in
Section 6.1. This code was optimized using JMP (N) instead of the initial jump to subroutine mechanisms.
This method of optimization is responsible for the difference between the speed of 169,145 cycles and
199,865 cycles of the ported code from the Section 6.1.
The explanation for the program memory increase and speed decrease is that every instruction that accepts
X:xxxx when encoded to X:xxxxxx is 1 word longer and takes 1 extra cycle.
Table 10. Summary of Extended Program Memory Size
Extended Program Memory
Size (Words)
Speed
(Cycles)
Data Program
Data memory extended (initial) 832 339 169145
Program memory extended 862 355 185292
Increase (percent) +3.6% +4.7% +9.5%
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...