📄 main.asm
字号:
.title "fir filter..."
.mmregs
.ref _c_int00
wave_ptr .set 062h
new_ad .set 063h
out_wave_ptr .set 064h
t_ar4 .set 065h
t_ar5 .set 066h
t_ar6 .set 067h
t_ar7 .set 068h
wave_buf .set 0900h
out_wave_buf .set 01000h
N .set 38
fir_coef_buf .set 100h
new_data_buf .set 200h
.text
_c_int00:
ssbx intm
ssbx sxm ;extend sign
ssbx frct ;fraction multiply
stm #10h,26h
stm #0ffh,sp
ld #0,dp
stm #0ffffh,ifr ;clear all int
;**********************************
;Initialize RAM.Variable...
;*********************************
stm #wave_buf,ar6
stm #1,ar0
rpt #24
mvpd wave_data,*ar6+0 ;move data to wave_buf
stm #wave_buf,wave_ptr ;save wave buffer_ptr
stm #out_wave_buf,out_wave_ptr ;save out wave buffer'ptr,
;because use circular address
; so when save out_wave date,must++
stm #fir_coef_buf,ar6
rpt #N-1
mvpd fir_coef,*ar6+ ;move fir coef to fir_coef_buf in data mem
stm #fir_coef_buf,t_ar2
stm #wave_buf,t_ar3
stm #out_wave_buf,t_ar4
stm #new_data_buff,t_ar5
;***************************************
;The following codes is used to FIR,new AD DATA in new_ad(0x64)
;FIR buffer coef->0x100(ar2), FIR window buffer->0x900(ar3)
;*********************************************
ld #100,b
mvdm #t_ar5,ar5
fir:
pshm st1
pshm st0
pshm bk
pshm ar7
pshm ah
pshm al
pshm ar0
pshm ar1
pshm ar2
pshm ar3
pshm ar4
mvdm #t_ar2,ar2
mvdm #t_ar3,ar3
mvdm #t_ar4,ar4
ld new_ad,-2,a
stl a,*ar5+
stm #1,ar0
stm #N,bk
stl a, *ar3+%
rptz a,#N-1 ;0->a ,then repeat 34 times
; done FIR filter,result in ah
mac *ar2+0%,*ar3+0%,a
mvmd ar3,#t_ar3
mvmd ar4,#t_ar2
stm #1,ar0
stm #100h,bk
sth a, *ar4+%
mvmd ar4,#t_ar4 ; give the output data to output data buffer
con_fir:
popm ar4
popm ar3
popm ar2
popm ar1
popm ar0
popm al
popm ah
popm ar7
popm bk
popm st0
popm st1
sub #1,b
bc fir,bneq
ld #100,b
nop
b fir
;***************************************
;The following data is used by make wave when using,must
;copy to wave_buffer->0x1000
;********************************************
wave_data:
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
;*********************************************************
;filter type lowpass
;filter length 38
;sampling 25.00000000
;upper band edge 1.20000005
;lower band edge 2.79999995
;**********************************************************
fir_coef:
.word 34
.word 235
.word 500
.word 735
.word 808
.word 587
.word 0
.word -914
.word -1972
.word -2854
.word -3163
.word -2518
.word -662
.word 2432
.word 6516
.word 11078
.word 15431
.word 18849
.word 20728
.word 20728
.word 18849
.word 15431
.word 11078
.word 6516
.word 2432
.word -662
.word -2518
.word -3163
.word -2854
.word -1972
.word -914
.word 0
.word 587
.word 808
.word 735
.word 500
.word 235
.word 34
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -