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

📄 iir4.asm

📁 关于滤波器的dsp实现
💻 ASM
字号:
;==============================================================
; Program Name: IIR.ASM
; This program implements a fourth order filter by
; optimizing the use of macd and the repeat instructions.
;==============================================================
; Reserve Data Memory
; The following section of code reserves data memory for
; the coefficients and data buffer  
;		.include	Dsp_init.h
;		.include	Dsp_vect.h
		.mmregs	
	.data
	.word	1234h
	.bss y1,10  ; y1 to y4 is output buffer
y2	.equ y1+1           
y3	.equ y1+2
y4	.equ y1+3           
*
u0	.equ y1+4  ; u0 to u4 is input buffer
u1	.equ y1+5
u2	.equ y1+6
u3	.equ y1+7
u4	.equ y1+8
*                            
YN	.word    00h
*      
OUTPUT_P	.usect 	"OUTPUT_P", 256
	.copy  "INPUT.inc"
* Input DATA: u(0), u(1), u(2), ..., u(N-1)
*	
	.copy  "IIR4COEF.h"
*	.word b4, b3, b2, b1, b0 
*  Coefficient table: B (reverse)
*	.word a4, a3, a2, a1
*  Coefficient table: A (reverse)
;==============================================================
;	b	_begin
;==============================================================
IIR4	.macro 
	lar		ar1, #u4  
	lacc	*+, ar1	;
	sacl	u0
	lacc	YN
	sacl	y1
	lacc	#0
	mpy		#0
	rpt		#9
	macd	Coefb4, *-
	mar		*, ar3   
; 0 + 0 + (u4*b4) +  (u3*b3)
; + (u2*b2) + (u1*b1) + (u0*b0)
; + (y4*a4) + (y3*a3) + (y2*a2) + (y1*a1)
	sach	YN
	sach	*+, ar2
;	sach	YN, 1
;	sach	*+,1, ar2
	.endm      
;----------------------	
IIRi	.macro
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	IIR4      
	.endm  
;------------------
IIR	.macro
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	IIRi	
	.endm   
;----------------------      
	.sect	"vectors"
		b	start                   
		b	0000h                   ;02; restart the monitor
		b	0000h                   ;04; restart the monitor
		b   0000h                   ;06; restart the monitor
		b	0000h                   ;08; restart the monitor
		b	0000h                 ;0a; restart the monitor
		b	0000h                   ;0c; restart the monitor
		.space 2*16                 ;0e; Reserved Space
		b	0000h                   ;10; restart the monitor
		b	0000h                   ;12; restart the monitor
		b	0000h                   ;14; restart the monitor
		b	0000h                   ;16; restart the monitor
		b	0000h                   ;18; restart the monitor
		b	0000h                   ;1a; restart the monitor
		b	0000h                   ;1c; restart the monitor
		b	0000h                   ;1e; restart the monitor
		b	0000h                   ;20; restart the monitor
		b	0000h                   ;22; restart the monitor
		b	0000h                   ;24; restart the monitor
		.space 2*16                 ;26; Reserved Space
		b	0000h                   ;28; restart the monitor
		b	0000h                   ;2a; restart the monitor
		b	0000h                   ;2c; restart the monitor
		b	0000h                   ;2e; restart the monitor
		b	0000h                   ;30; restart the monitor
		b	0000h                   ;32; restart the monitor
		b	0000h                   ;34; restart the monitor
		b	0000h                   ;36; restart the monitor
		b	0000h                   ;38; restart the monitor
		b	0000h                   ;3a; restart the monitor
		b	0000h                   ;3c; restart the monitor
		b	0000h                   ;3e; restart the monitor

;============================
	.text
start            
	nop
	nop
	nop
	nop
	setc 	INTM ;global interrupt disable
	setc 	SXM
	setc	OVM
	spm		00
;=====================================
	lar		ar1, #y1
	lacl	#0
	mar		*, ar1
	rpt		#10-1
	sacl    *+
	ldp	 	#y1 ;be on y1’s page
	lar		ar2, #INPUT_P
	lar		ar3, #OUTPUT_P
;	lar		ar1, #u4  
	mar		*, ar2
	IIR
	b 		$
			ret              

	.end      

⌨️ 快捷键说明

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