/* This C language subroutine computes the Finite Impulse Response (FIR) filter specified by its floating point input, coefficients, and delay line. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 6/23/90 Updated on 5/94 by AS Updated on 1/95 by AS - separated polymorphic functions #include
float fir(float sample, float coeffs[], \ float *state[], int taps); */ #include "lib_glob.h" #include "trn_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _fir; _fir: ___firPD: pm_lnt=0; fircore: put(R10); R2=PASS R12,readparam4(R12); /*Read taps*/ R1=MODE1; /*Save old mode*/ BIT SET MODE1 65536; /*Set to 40-BIT mode*/ pm_dm_fir: R10=dma_i; /*Hold extra DM pointer*/ R2=R2+1, dma_i=R2; /*R2+1-->base,dma_i-->delay*/ dm_bse=R2; /*Set base pointer*/ dm_lnt=R12; /*Set length pointer*/ R0=DM(dm_0,dma_i); /*Rd ptr to delay location*/ R0=PASS R0, pm_ptr=R8; /*Point to delay location*/ IF EQ R0=R2; /*Init access, set delay to 0*/ R0=PASS R12, dm_ptr=R0; /*Point to delay location*/ R2=R2-R2, DM(dm_ptr,dm_1)=R4; /*Store input in delay line*/ R8=R8-R8, R4=dm_ptr; R12=R12-R12, DM(dm_0,dma_i)=R4;/*Store new delay pointer*/ LCNTR=R0, DO pdconv UNTIL LCE; pdconv: F8=F2*F4, F12=F8+F12, F4=DM(dm_ptr,dm_1), F2=PM(pm_ptr,pm_1); F8=F2*F4, F12=F8+F12; F0=F8+F12, dma_i=R10; /*Restore extra DM pointer*/ restore_state: FETCH_RETURN dm_lnt=0; /*Rest this to 0 */ MODE1=R1; /*Restore old mode*/ get(R10,1); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;