Outer Loop Conditionally Executed With Inner Loop
6-138
6.14.3 Translating C Code to Linear Assembly (Outer Loop)
Example 6–74 shows the instructions that execute all of the outer loop func-
tions. All of these instructions are conditional on inner loop counters. Two
different counters are needed, because they must decrement to 0 on different
iterations.
-
The resetting of the x and h pointers is conditional on the pointer reset
counter, prc.
-
The shifting and storing of the even and odd y elements are conditional on
the store counter, sctr.
When these counters are 0, all of the instructions that are conditional on that
value execute.
-
The MVK instruction resets the pointers to 8 because after every eight
iterations of the loop, a new inner loop is completed (8
4 elements are
processed).
-
The pointer reset counter becomes 0 first to reset the load pointers, then
the store counter becomes 0 to shift and store the result.
Example 6–74. Linear Assembly for FIR Outer Loop
[sctr]
SUB
sctr,1,sctr
; dec store lp cntr
[!sctr]
SHR
sum07,15,y0
; (sum0 >> 15)
[!sctr]
SHR
sum17,15,y1
; (sum1 >> 15)
[!sctr]
STH
y0,*y++[2]
; y[j] = (sum0 >> 15)
[!sctr]
STH
y1,*y_1++[2]
; y[j+1] = (sum1 >> 15)
[!sctr]
MVK
4,sctr
; reset store lp cntr
[pctr]
SUB
pctr,1,pctr
; dec pointer reset lp cntr
[!pctr]
SUB
x,rstx2,x
; reset x ptr
[!pctr]
SUB
x_1,rstx1,x_1
; reset x_1 ptr
[!pctr]
SUB
h,rsth1,h
; reset h ptr
[!pctr]
SUB
h_1,rsth2,h_1
; reset h_1 ptr
[!pctr]
MVK
4,pctr
; reset pointer reset lp cntr
6.14.4 Unrolled FIR Filter C Code
The total number of instructions to execute both the inner and outer loops is
38 ( 26 for the inner loop and 12 for the outer loop). A 4-cycle loop is no longer
possible. To avoid slowing down the throughput of the inner loop to reduce the
outer-loop overhead, you must unroll the FIR filter again.
Example 6–75 shows the C code for the FIR filter, which operates on eight
elements every inner loop. Two outer loops are also being processed together,
as in Example 6–72 on page 6-136.