?? iirform2.asm
字號:
;
; iirform2.asm IIR direct form II (biquads) IIR filter
;
; Prototype: void iirform2(int *, unsigned int, int *, int *, unsigned int, int *);
;
; Entry: arg0: AR0-filter input sample buffer pointer
; arg1: T0-number of samples in input buffer
; arg2: AR2-output sample buffer pointer
; arg3: AR1-IIR coefficients array pointer
; arg4: T1-number of biquads IIR sections
; arg5: AR3-delayline pointer
;
;
; Direct form II - IIR filter (the ith sections):
; d(n) = x(n) - ai1*d(n-1)-ai2*d(n-2)
; y(n) = bi0*d(n) + bi1*d(n-1) + bi2*d(n-2)
;
; Memory arrangement and initialization: (1,2,...i,..,Ns)
; tempbuf[2*Ns] coefficient[5*Ns]
; AR3 -> w1i AR7 -> a1i
; w1j a2i
; : b2i
; w2i b0i
; w2j b1i
; : :
;
; Scale: Coefficient is in Q14 format
; The filter result is scaled up to compensate the Q14 coefficient
;
.global _iirform2
.sect "iir_code"
_iirform2
pshm ST1_55 ; Save ST1, ST2, and ST3
pshm ST2_55
pshm ST3_55
psh T3 ; Save T3
pshboth XAR7 ; Save AR7
or #0x340,mmap(ST1_55) ; Set FRCT,SXMD,SATD
bset SMUL ; Set SMUL
sub #1,T0 ; Number of samples - 1
mov T0,BRC0 ; Set up outer loop counter
sub #1,T1,T0 ; Number of sections -1
mov T0,BRC1 ; Set up inner loop counter
mov T1,T0 ; Set up circular buffer sizes
sfts T0,#1
mov mmap(T0),BK03 ; BK03=2*number of sections
sfts T0,#1
add T1,T0
mov mmap(T0),BK47 ; BK47=5*number of sections
mov mmap(AR3),BSA23 ; Initial delay buffer base
mov mmap(AR2),BSA67 ; Initial coefficient base
amov #0,AR3 ; Initial delay buffer entry
amov #0,AR7 ; Initial coefficient entry
or #0x88,mmap(ST2_55)
mov #1,T0 ; Used for shift left
|| rptblocal sample_loop-1 ; Start IIR filter loop
mov *AR0+ <<#14,AC0 ; AC0 = x(n)/2 (i.e. Q14)
|| rptblocal filter_loop-1 ; Loop for each section
masm *(AR3+T1),*AR7+,AC0 ; AC0-=ai1*di(n-1)
masm T3=*AR3,*AR7+,AC0 ; AC0-=ai2*di(n-2)
mov rnd(hi(AC0<<T0)),*AR3 ; di(n-2)=di(n)
|| mpym *AR7+,T3,AC0 ; AC0+=bi2*di(n-2)
macm *(AR3+T1),*AR7+,AC0 ; AC0+=bi0*di(n-1)
macm *AR3+,*AR7+,AC0 ; AC0+=bi1*di(n)
filter_loop
mov rnd(hi(AC0<<#2)),*AR1+ ; Store result in Q15
sample_loop
popboth XAR7 ; Restore AR7
pop T3 ; Restore T3
popm ST3_55 ; Restore ST1, ST2, and ST3
popm ST2_55
popm ST1_55
ret
.end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -