/* 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 ___firPP; ___firPP: pm_lnt=0; fircore: R0=R0-R0, put(R15); /*In case of fall thru on err*/ R15=PASS R4, put(R14); R14=PASS R8, put(R10); put(R13); R13=PASS R12,readparam4(R12); /*Read taps*/ R1=MODE1; /*Save old mode*/ BIT SET MODE1 65536; /*Set to 40-BIT mode*/ pm_pm_fir: R10=dma_i; /*Hold extra DM pointer*/ R13=R13+1, dma_i=R13; /*R13+1-->base,dma_i-->delay*/ dm_bse=R13; /*Set base pointer*/ dm_lnt=R12; /*Set length pointer*/ R0=DM(dm_0,dma_i); /*Read ptr to delay loc*/ R0=PASS R0, pm_ptr=R14; /*Point to delay location*/ IF EQ R0=R13; /*Init access,set delay to 0*/ R13=PASS R12, dm_ptr=R0; /*Pt to delay location*/ R2=R2-R2, DM(dm_ptr,dm_1)=R15; /*Store input in delay line*/ R8=R8-R8, R15=dm_ptr; R12=R12-R12, DM(dm_0,dma_i)=R15;/*Store new delay ptr*/ LCNTR=R13, 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 ptr*/ restore_state: FETCH_RETURN dm_lnt=0; /*Restore this to 0*/ MODE1=R1; /*Restore old mode*/ get(R13,1); get(R10,2); get(R14,3); get(R15,4); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;