Memory Banks
6-123
Optimizing Assembly Code via Linear Assembly
6.12.3 Translating C Code to Linear Assembly
Example 6–67 shows the linear assembly for the unrolled inner loop of the FIR
filter C code.
Example 6–67. Linear Assembly for Unrolled FIR Inner Loop
LDH
*x++,x1
; x1 = x[j+i+1]
LDH
*h++,h0
; h0 = h[i]
MPY
x0,h0,p00
; x0 * h0
MPY
x1,h0,p10
; x1 * h0
ADD
p00,sum0,sum0
; sum0 += x0 * h0
ADD
p10,sum1,sum1
; sum1 += x1 * h0
LDH
*x++,x2
; x2 = x[j+i+2]
LDH
*h++,h1
; h1 = h[i+1]
MPY
x1,h1,p01
; x1 * h1
MPY
x2,h1,p11
; x2 * h1
ADD
p01,sum0,sum0
; sum0 += x1 * h1
ADD
p11,sum1,sum1
; sum1 += x2 * h1
LDH
*x++,x3
; x3 = x[j+i+3]
LDH
*h++,h2
; h2 = h[i+2]
MPY
x2,h2,p02
; x2 * h2
MPY
x3,h2,p12
; x3 * h2
ADD
p02,sum0,sum0
; sum0 += x2 * h2
ADD
p12,sum1,sum1
; sum1 += x3 * h2
LDH
*x++,x0
; x0 = x[j+i+4]
LDH
*h++,h3
; h3 = h[i+3]
MPY
x3,h3,p03
; x3 * h3
MPY
x0,h3,p13
; x0 * h3
ADD
p03,sum0,sum0
; sum0 += x3 * h3
ADD
p13,sum1,sum1
; sum1 += x0 * h3
[cntr] SUB
cntr,1,cntr
; decrement loop counter
[cntr] B
LOOP
; branch to loop