www.pudn.com > DSP_fir.rar > fir.asm, change:2004-07-05,size:1789b


;一个FIR滤波器源程序  fir.asm 
			.mmregs 
			.global start 
			.def  	start,_c_int00 
			     				 
INDEX 		.set 	1 
KS			.set  	256 					;模拟输入数据缓冲区大小 
 
N           .set    17 		            	 
COFF_FIR	.sect  "COFF_FIR"				;FIR滤波器系数 
			.word  0 
			.word  158 
			.word  264 
			.word  -290 
			.word  -1406 
			.word  -951 
			.word  3187 
			.word  9287 
			.word  12272 
			.word  9287 
			.word  3187 
			.word  -951 
			.word  -1406 
			.word  -290 
			.word  260 
			.word  158 
			.word  0 
		    .data 
INPUT	    .copy  	"firin.inc"            ;模拟输入在数据存储区0x2400 
OUTPUT		.space	1024                   ;输出数据在数据区0x2500 
;FIR_DP		.usect	"FIR_VARS",0 
;D_FIN		.usect	"FIR_VARS",1 
;D_FOUT		.usect	"FIR_VARS",1           
COFFTAB	    .usect	"FIR_COFF",N 
DATABUF		.usect	"FIR_BFR",N 
BOS			.usect	"STACK",0Fh 
TOS			.usect	"STACK",1  
 
			.text 
			.asg	AR0,INDEX_P 
			.asg	AR4,DATA_P	;输入数据x(n)循环缓冲区指针 
			.asg	AR5,COFF_P	;FIR系数表指针 
			.asg 	AR6,INBUF_P ;模拟输入数据指针 
		 	.asg	AR7,OUTBUF_P;FIR滤波器输出数据指针 
_c_int00 
		b start  
		nop 
		nop 
start:  ssbx  FRCT    
		STM 	#COFFTAB,COFF_P 
		RPT 	#N-1 				;将FIR系数从程序存储器移动 
		MVPD	#COFF_FIR,*COFF_P+	;到数据存储器 
		 
		STM		#INDEX,INDEX_P	 
		STM		#DATABUF,DATA_P 
		RPTZ	A,#N-1 
		STL		A,*DATA_P+			;将数据循环缓冲区清零 
		 
		STM		#(DATABUF+N-1),DATA_P ;数据缓冲区指针指向x[n-(N-1)] 
		STM		#COFFTAB,COFF_P		; 
FIR_TASK: 
        STM		#INPUT,INBUF_P		 
        STM 	#OUTPUT,OUTBUF_P     
        STM		#KS-1,BRC 
        RPTBD	LOOP-1 
        STM		#N,BK				;FIR循环缓冲区大小 
        LD		*INBUF_P+,A			;装载输入数据 
FIR_FILTER: 
 		STL		A,*DATA_P+% 
 		RPTZ	A,N-1 
 		MAC		*DATA_P+0%,*COFF_P+0%,A 
 		STH		A,*OUTBUF_P+ 
LOOP: 
EEND	B 	EEND 
 		.end