📄 firs.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
;*****************************************************************
; Function: firs
; Description: implements symmetric finite impulse response filter
;
; Copyright Texas instruments Inc, 1998
;----------------------------------------------------------------
; Revision History:
; 1.00, K. Baldwin. 08/31/98. Original release.
;****************************************************************
;----------------------------------------------------------------
; Global symbols used by this Function:
; TI_FIRS_COEFFS
; This symbol is used as the universal symbol for the label in
; program space pointing to start of coefficient table for the
; symmetric filter function.
;----------------------------------------------------------------
.global _TI_FIRS_COEFFS
.mmregs
;----------------------------------------------------------------
; Adjust offset for far mode
;----------------------------------------------------------------
.if __far_mode
.asg 2, OFFSET
.else
.asg 1, OFFSET
.endif
;----------------------------------------------------------------
; Define space reserved on stack for register save area
;----------------------------------------------------------------
.asg 4, REGISTER_SAVE_SZ
;----------------------------------------------------------------
; Define size of space to reserve on stack for local variables
;----------------------------------------------------------------
.asg 1, FRAME_SZ
.asg 0, round_off
;----------------------------------------------------------------
; Define stack offsets to function arguments
;----------------------------------------------------------------
.asg OFFSET + REGISTER_SAVE_SZ + FRAME_SZ, PARAM_OFFSET
.asg 0 + PARAM_OFFSET, r_addr
.asg 1 + PARAM_OFFSET, db_addr_ptr
.asg 2 + PARAM_OFFSET, nh
.asg 3 + PARAM_OFFSET, nx
;---------------------------------------------------------------
; Register assignments for local vraibles
;---------------------------------------------------------------
.asg BRC, nsamps
.asg AR2, outbuf_ptr
.asg AR3, db1_ptr
.asg AR4, db2_ptr
.asg AR1, buff_len
.asg AR5, sample_buff_ptr
.text
.global _firs
_firs
;---------------------------------------------------------------
;* Save contents of AR1, AR5, and AR6
;---------------------------------------------------------------
pshm ar1 ; 1 cycle
pshm ar5 ; 1 cycle
PSHM ST0 ; 1 cycle
PSHM ST1 ; 1 cycle
RSBX OVA ; 1 cycle
RSBX OVB ; 1 cycle
frame #-FRAME_SZ ; 1 cycle
rsbx sxm ; 1 cycle
stlm a, sample_buff_ptr ; 1 cycle , AR5 = input buf address
ssbx frct ; 1 cycle
st #8000h, *sp(round_off) ; 2 cycles
ssbx sxm ; 1 cycle
;--------------------------------------------------------------
; Process function arguments
;--------------------------------------------------------------
ld *sp(db_addr_ptr), a ; 1 cycle , A = address of delay buffer
stlm a, db1_ptr ; 1 cycle , AR3 = top of buffer
mvdk *sp(r_addr), outbuf_ptr ; 2 cycles, AR2 = output buffer
ld *sp(nx), a ; 1 cycle
sub #1, a ; 2 cycles
stlm a, nsamps ; 1 cycle , BRC = nx - 1
ld *sp(nh), a ; 1 cycle
stlm a, buff_len ; 1 cycle
sfta a, 1, a ; 1 cycle
stlm a, BK ; 1 cycle , BK = buffer length
ld *db1_ptr, b ; 1 cycle
stlm b, db1_ptr ; 1 cycle
add #1, b ; 1 cycle
stlm b, db2_ptr ; 1 cycle , AR4 = delay buffer n/2
mar *buff_len- ; 1 cycle , nh-1 = nh loops
;--------------------------------------------------------------
; Main loop, for each data sample - apply filter
;--------------------------------------------------------------
rptbd end_loop-1 ; 2 cycles
stm #2, AR0 ; 2 cycles
;--------------------------------------------------------------
; Get next input sample from input data buffer
;--------------------------------------------------------------
ld *sample_buff_ptr+, A ; 1 cycle
ldu *sp(round_off), b ; 1 cycle
;--------------------------------------------------------------
; Write sample -N/2 to oldest sample -N X[-N/2] , X[-N]
;--------------------------------------------------------------
MVDD *db1_ptr, *db2_ptr+0% ; 2 cycles
;--------------------------------------------------------------
; Replace oldest sample in upper 8 samples with newest
; sample data
;--------------------------------------------------------------
stl A, *db1_ptr ; 1 cycle
;--------------------------------------------------------------
; Add x[0] to x[(-n/2)-1]
;--------------------------------------------------------------
add *db1_ptr+0%, *db2_ptr+0%, A ; 1 cycle
;--------------------------------------------------------------
; Process remaining elements
;--------------------------------------------------------------
rpt *(buff_len) ; 2 cycles
firs *db1_ptr+0%, *db2_ptr+0%, _TI_FIRS_COEFFS ; 3 + ncoeffs - 2
;--------------------------------------------------------------
; Adjust pointers to next element
;--------------------------------------------------------------
mar *+db1_ptr(-4)% ; 2 cycles
mar *db2_ptr-0% ; 1 cycle
sth b,*outbuf_ptr+ ; 1 cycle
end_loop:
ldm db1_ptr, b ; 1 cycle
mvdk *sp(db_addr_ptr), db1_ptr ; 2 cycles
ld #0, a ; 1 cycle
xc 1, BOV ; 1 cycle
ld #1, a ; 1 cycle
frame #(FRAME_SZ) ; 1 cycle
POPM ST1 ; 1 cycle
POPM ST0 ; 1 cycle
popm ar5 ; 1 cycle
popm ar1 ; 1 cycle
.if __far_mode
fretd ; 4 cycles
.else
retd ; 3 cycles
.endif
nop ; delay slot 1 cycle
stl b, *db1_ptr ; delay slot 1 cycle
;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 + -