C CODE VS. DSP CODE
C/C++ Code:
double cfir1(int M, double* h,
double* w, double** p, double x) {
*(*p)-- = x;
wrap(M, w, p);
for (double y=0, h+=M, int i=M; i>=0; i--) {
y += (*h--) * (*(*p)--);
wrap(M,w,p);
}
return y;
}
DSP Code:
NEWX LDF IN, R3 read new input sample
STF R3, *AR1++% put x in a register and increment
LDF 0.0, R0 initialize accumulators
LDF 0.0, R2
RPTS M repeat for i=M to i=0
MPYF3 *AR0++%, *AR1++%, R0 calculate and in parallel
|| ADDF3 R0, R2, R2 accumulate
ADDF R0, R2 accumulate last product
STF R2, Y output
B NEWX branch and repeat