⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iir.asm

📁 语音信号进行Fir滤波
💻 ASM
字号:
/*
	This C language subroutine computes the Infinite
	Impulse Response (IIR) filter specified by 
	its floating point input, coefficients, and state.
	
	The Run Time Library for the C Language.

	Gordon A. Sterling	(617) 461 - 3076
	DSP Development Tools Engineering
	
	Created on 6/24/90
	Updated on 5/94 by AS
	Updated on 1/95 by AS - separated polymorphed functions
	Updateed on 11/96 by Jing Li - See the following

  	  The major section of this piece of code has been rewritten. 
	The reason for that is that when the test program
	libfloat/filters.c called this function, only one out of
	20 returned outputs was correct from iir.asm.

	  Referring Direct Form II for algorithm for this function.
	There two steps from an input x[n] to the corresponding
	output y[n]:
		w[n]=x[n]+a[0]*w[0]+...+a[n-1]*w[n-1]
	and
		y[n]=b[0]*w[0]+...+b[n]*w[n]
	
	where w[] is the intermediate matrix.

	Note: The notation used here for coding  might be different 
	from that used in other books.


	Algorithm:

		w[n]=x[n];	{Update w[n] for each x[n]}
		for(i=0; i<n; i++)
		   w[n]=w[n]+a[i]*w[i];

		y[n]=0;		{Compute y[n] and update w[i]}
		for(i=0; i<=n; i++) {
		   y[n]=y[n]+b[i]*w[i];
		   w[i]=w[i+1];		{Update w[i]}
		}

		F0=y[n];	{return value}


Registers and stack for passing paramters:
	F4: x[n]
	R8: &a[]   coefficients
	F12: &b[]  coefficients
	stack: &w[]
	stack: taps

Registers for return value
	F0: y[n]

Registers altered
	R10
	R11

	#include <trans.h>				    <Header>

	float iir(  float sample, \			    <Prototype>
		    float pm a_coeffs[], float pm b_coeffs[], \
		    float state[], int taps);
*/

#include "lib_glob.h"
#include "trn_glob.h"

.section/CODE	Code_Space_Name;
.FILE 		RTL_FILENAME;

.GLOBAL	    	_iir;

/*  a_coeff, b_coeff, state */

_iir:
___iirPPD:	
iir_core:	R1=PASS R12, put(R10);		/*R1: &b[0]*/
	    	readparam5(R12);		/*R12: taps*/
	    	R12=PASS R12, put(R11); 	/*Test for taps ==0	*/
		IF EQ JUMP (PC, restore_state) (DB);
		readparam4(R2);			/* &w[0] */
		R11=MODE1;

		BIT CLR MODE1 65536;		/*Set 40-BIT mode	*/
pm_pm_dm_iir:	
		R0=PASS R12, pm_ptr=R8;	/*Save taps. Addr. of a_coeff*/
		R8=R8-R8, dm_ptr=R2;	/*Addr. of delay line w[0]*/
		F12=PASS F4, R10=R2;	/*F12: sample.R10: ptr to delay line*/
		F4=DM(dm_ptr, dm_1), F2=PM(pm_ptr, pm_1);
		/*1st ele in delay line w[0]. 1st ele in a[0]*/

		LCNTR=R0, DO ppdpole_loop UNTIL LCE;
ppdpole_loop:	  F8=F2*F4, F12=F8+F12, F4=DM(dm_ptr,dm_1), F2=PM(pm_ptr,pm_1);
		F12=F8+F12, pm_ptr=R1;/*F12: delay line w(n). Addr of b[0]*/
		R8=R8-R8, DM(dm_M1,dm_ptr)=F12; /*Save w(n)*/
		R12=R12-R12, dm_ptr=R10;/*dm_ptr pt to w[0] again*/
		F4=DM(dm_ptr,dm_1), F2=PM(pm_ptr,pm_1);

		LCNTR=R0, DO ppdzero_loop UNTIL LCE;
		  F8=F2*F4, F12=F8+F12, F4=DM(dm_ptr,dm_1), F2=PM(pm_ptr,pm_1);
ppdzero_loop:	  DM(-2,dm_ptr)=R4;	/*Update w[]*/
		F8=F2*F4, F12=F8+F12;	
		F0=F8+F12;	/*Return value y[n]*/

restore_state:	FETCH_RETURN
		MODE1=R11;			/*Restore old mode*/
		get(R11,1);
		get(R10,2);
		RETURN (DB);
		RESTORE_STACK
		RESTORE_FRAME

_iir.end:



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -