📄 iircas51.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
;*****************************************************************************
; Function: iircas51
; Description: cascaded IIR direct form I using 5-coefs per biquad
;
; Copyright Texas instruments Inc, 1998
;-----------------------------------------------------------------------------
; Revision History
; 1.00 R. Piedra, 8/31/98. Original version. Started from code by Jeff Hayes.
; 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_ar7 ; stack description
.asg (3), save_ar6
.asg (4), save_ar1
.asg (5), ret_addr
; x in A
.asg (6 + offset), arg_h
.asg (7 + offset), arg_y
.asg (8 + offset), arg_d
.asg (9 + offset), arg_nbiq
.asg (10 + offset), arg_n
; register usage
; AR0: circ addr index
.asg ar1, ar_x ;
.asg ar2, ar_d ;
.asg ar3, ar_h ;
.asg ar4, ar_y ;
.asg ar5, ar_count ;
.asg ar6, ar_hsave ;
.asg ar7, ar_dsave ;
;******************************************************************************
.def _iircas51
_iircas51:
; Preserve registers
;-------------------
pshm ar1 ; preserve registers (1)
pshm ar6 ; (1)
pshm ar7 ; (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)
; Get arguments
;--------------
; 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_dsave) ; de-referencing (2)
mvdk *ar_dsave,*(ar_dsave) ; pointer to d (2)
ld *sp(arg_nbiq),a ; a = nbiq (2)
sub #1,a,b ; (2)
stl b, *sp(arg_nbiq) ; nbiq(stack) = nbiq-1 (1)
mvdk *sp(arg_n),*(ar_count) ; sample counter (2)
mar *ar_count- ; ar_count = nsamples-1 (1)
stm #2,AR0 ; used for incrementing ar_d (2)
; Loop through N samples
;-----------------------
_start:
next_sample
; Loop each sample through N biquads
;-----------------------------------
mvdk *sp(arg_nbiq), BRC ; BRC <- (nbiq -1) (2)
mvmm ar_hsave,ar_h ; reinitialize pointer to top (1)
mvmm ar_dsave,ar_d ; reinitialize pointer to top (1)
rptbd eloop-1 ; (2)
ld *ar_x+, 16, a ; ah = x(n) = new sample (1)
nop ; (1)
mpya *ar_h+ ; B = (a= x(n))* b0 (1)
; T = b0
mac *ar_d+,*ar_h+,b ; B += x(n-1)*b1 (1)
; T = x(n-1)
mac *ar_d-,*ar_h+,b ; B += x(n-2)*b2 (1)
; T=x(n-2)
; B = x(n)*b0 + x(n-1)*b1 + x(n-2)*b2
delay *ar_d ; x(n-2) = x(n-1) (1)
sth a,*ar_d+0 ; x(n-1) = x(n) (1)
mas *ar_d,*ar_h,b ; b -= a1/2*y(n-1) (1)
mas *ar_d+,*ar_h+,b ; b -= a1/2*y(n-1) (1)
mas *ar_d-,*ar_h+,b,a ; b -= a2*y(n-2) (1)
eloop
delay *ar_d ; y(n-2) = y(n-1) (1)
banzd next_sample, *ar_count- ; compute next example (2)
sth a,*ar_d ; y(n-1) = y(n) (1)
sth a,*ar_y+ ; store y(n) (1)
; Return
;-------
_end:
mvmm ar_dsave,ar_d ; reinitialize pointer to top (1)
; to allow dual buffering
; OJO : NOT REALLY NEEDED
.asg ar_h, ar_temp ; ar_h not used anymore
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 ; if either a or b overflow (1)
xc 1, BOV ; (1)
ld #1,a ; (1)
POPM ST1 ; 1 cycle
POPM ST0 ; 1 cycle
popm ar7 ; (1)
popm ar6 ; (1)
popm ar1 ; (1)
.if __far_mode
fretd ; (4)
.else
retd ; (3)
.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 + -