📄 iircas4.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
;*****************************************************************************
; Function: iircas4
; Description: cascaded IIR direct form II using 4-coefs per biquad
;
; Copyright Texas instruments Inc, 1998
;-----------------------------------------------------------------------------
; Revision History:
; 1.00 R. Piedra, 8/31/98. Original version. Started from code by Greg Peake.
; 2.00 Li Yuan, 6/08/01. Fixed the problem of overflow.
; 3.00 Cesar Iovescu, 10/04/01. Use a1/2 insead of a1 to avoid overflow.
;*****************************************************************************
.mmregs
; Far-mode adjustment
.if __far_mode
offset .set 1 ; far mode uses one extra location for ret addr ll
.else
offset .set 0
.endif
.asg (2), save_ar6 ; stack description
.asg (3), save_ar1
.asg (4), ret_addr
; x in A
.asg (5 + offset), arg_h
.asg (6 + offset), arg_y
.asg (7 + offset), arg_d
.asg (8 + offset), arg_nbiq
.asg (9 + offset), arg_n
; register usage
; ar0: circ addr. idx
.asg ar1, ar_x
.asg ar2, ar_d
.asg ar3, ar_h
.asg ar4, ar_y
.asg ar5, ar_count
.asg ar6, ar_hsave
;*****************************************************************************
.def _iircas4
.text
_iircas4
; Preserve registers
;-------------------
pshm ar1 ; (1)
pshm ar6 ; (1)
PSHM ST0 ; 1 cycle
PSHM ST1 ; 1 cycle
RSBX OVA ; 1 cycle
RSBX OVB ; 1 cycle
ssbx sxm ; sign extension on (1)
ssbx frct ; fract on (1)
ld #0,ASM ; clear ASM (st||mac) (1)
; Get arguments
;--------------
stlm a, ar_x ; pointer to x (1)
mvdk *sp(arg_h),*(ar_hsave) ; pointer to h (2)
mvdk *sp(arg_y),*(ar_y) ; pointer to y (2)
mvdk *sp(arg_d),*(ar_d) ; de-referencing (2)
mvdk *ar_d,*(ar_d) ; pointer to d (2)
mvdk *sp(arg_nbiq),*(ar0) ; for circ addr (2)
mvdk *sp(arg_n),*(ar_count) ; sample counter (2)
mar *ar_count- ; ar_count=nsamples -1 (1)
ldm ar0,a ; a = nbiq (1)
sub #1,a, b ; b = nbiq -1 (store in brc later) (2)
ld a, 1, a ; a = nbiq * 2 (1)
stlm a, bk ; circ buffer size = nbiq*2 (1)
; Loop through N samples
;-----------------------
; d(n) = x(n) - a1*d(n-1) - a2*d(n-2)
; y(n) = d(n) + b1*d(n-1) + b2*d(n-2)
; coef. order : a1 a2 b2 b1 .... other biquads
; delay buffer order : d1(n-1) d2(n-1) .... d1(n-2) d2(n-2)....
; d1 = for biquad 1
; d2 = for biquad 2
_start:
next_sample
stlm b,brc ; loop nbiq times(each sample) (1)
mvmm ar_hsave,ar_h ; reinitialize h pointer to top (1)
; Loop each sample through n biquads
;-----------------------------------
rptbd eloop-1 ; (2)
ld *ar_x+,16,a ; ah = x0 = new sample (1)
nop ; (1)
mas *ar_d,*ar_h,a ; a -= d(n-1) * a1/2 (1)
; t = d(n-1)(no use)
mas *ar_d+0%,*ar_h+,a ; a -= d(n-1) * a1
; point to d(n-2)
mas *ar_d, *ar_h+, a ; a -= d(n-2) * a2 (1)
; t = d(n-2)
; point to d(n-2)
; d(n) = a = x0 - a1*d(n-1) - a2*d(n-2) complete
st a, *ar_d+0% ; d(n-2) = new d(n) (1)
; replace oldest
; point to d(n-1)
|| mac *ar_h+, a ; a += b2 * (t=d(n-2))
mac *ar_d+, *ar_h+, a ; a += d(n-1) * b1 (1)
; point to next biq d(n-1)
; point to next biq a1
eloop
; all biquads completed
; store output sample
;---------------------
sth a, *ar_y+ ; store output in Q15 (1)
banzd next_sample, *ar_count- ; compute next sample (2)
mar *ar_d- ; correct ar_d overshoot (1)
mar *ar_d+% ; modify for circ addr (1)
; Return
;--------
_end:
.asg ar_h, ar_temp ; ar_h not used any more
mvdk *sp(arg_d),*(ar_temp) ; (2)
mvkd *(ar_d), *ar_temp ; update new ar_d (2)
ld #0,a ; (1)
xc 1, AOV ; return overflow flag (1)
ld #1,a ; (1)
POPM ST1 ; 1 cycle
POPM ST0 ; 1 cycle
popm ar6 ; (1)
popm ar1 ; (1)
.if __far_mode
fretd ; (6)
.else
retd ; (6)
.endif
nop
nop
;end of file. please do not remove. it is left here to ensure that no lines of code are removed by any editor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -