Digital Signal Processing Reference
In-Depth Information
3. Select
Animate (introduced in Chapter 1). Execution halts at the
set breakpoint for each unit of time. Observe the end (bottom) memory loca-
tion of the delay samples' buffer. Verify that the newest sample data value is
placed at the end of the buffer. This value is then moved up the buffer to a
lower address. Observe after a while that the samples are being updated, with
each value in the buffer moving up in memory. You can also observe the reg-
ister (pointer) A4 incrementing by 2 (two bytes) and B4 decrementing by 2.
Æ
Debug
Æ
Example 4.12: FIR Implementation Using C Calling a Faster
ASM Function ( FIRcasmfast )
The same C calling program, FIRcasm.c , is used in this example as in Example
4.11. It calls the ASM function Fircasmfunc within the file FIRcasmfunc-
fast.asm , as shown in Figure 4.33. This ASM function executes faster than the
function in the previous example by having parallel instructions and rearranging the
sequence of instructions. There are two parallel instructions: LDH/LDH and
SUB/LDH .
1. The number of NOP s is reduced from 19 to 11.
2. The SUB instruction to decrement the loop count is moved up the program.
3. The sequence of some instructions is changed to “fill” some of the NOP slots.
; FIRCASMfuncfast.asm C-called faster function to implement FIR
.def _fircasmfunc
_fircasmfunc: ;ASM function called from C
MV A6,A1 ;setup loop count
MPY A6,2,A6 ;since dly buffer data as byte
ZERO A8 ;init A8 for accumulation
ADD A6,B4,B4 ;since coeff buffer data as byte
SUB B4,1,B4 ;B4 = bottom coeff array h[N-1]
loop: ;start of FIR loop
LDH *A4++,A2 ;A2 = x[n-(N-1)+i] i=0,1,...,N-1
|| LDH *B4--,B2 ;B2 = h[N-1-i] i=0,1,...,N-1
SUB A1,1,A1
;decrement loop count
||
LDH *A4,A7 ;A7=x[(n-(N-1)+i+1]update delays
NOP 4
STH A7,*-A4[1] ;-->x[(n-(N-1)+i] update sample
[A1]
B loop
;branch to loop if count # 0
NOP 2
MPY A2,B2,A6 ;A6=x[n-(N-1)+i]*h[N-1-i]
NOP
ADD A6,A8,A8 ;accumlate in A8
B B3 ;return addr to calling routine
MV A8,A4 ;result returned in A4
NOP 4
FIGURE 4.33. FIR ASM function with parallel instructions for faster execution
( FIRcasmfuncfast.asm ).
Search WWH ::




Custom Search