Outer Loop Conditionally Executed With Inner Loop
6-140
6.14.5 Translating C Code to Linear Assembly (Inner Loop)
Example 6–76 shows the instructions that perform the inner and outer loops
of the FIR filter. These instructions reflect the following modifications:
-
LDWs are used instead of LDHs to reduce the number of loads in the loop.
-
The reset pointer instructions immediately follow the LDW instructions.
-
The first ADD instructions for sum0 and sum1 are conditional on the same
value as the store counter, because when sctr is 0, the end of one inner
loop has been reached and the first ADD, which adds the previous sum07
to p00, must not be executed.
-
The first ADD for sum0 writes to the same register as the first MPY p00.
The second ADD reads p00 and p01. At the beginning of each inner loop,
the first ADD is not performed, so the second ADD correctly reads the
results of the first two MPYs (p01 and p00) and adds them together. For
other iterations of the inner loop, the first ADD executes, and the second
ADD sums the second MPY result (p01) with the running accumulator. The
same is true for the first and second ADDs of sum1.