📄 firlat.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
*********************************************************************************
; Function: firlat
; Description: Lattice FIR filter implementation
;
; Copyright Texas instruments Inc, 1998
;-------------------------------------------------------------------------------
; Revision History:
; 1.00, A. Aboagye, 8/31/98 - Original release. From code by C. Chow & P. Ponce
;
;********************************************************************************
.mmregs
.if __far_mode
OFFSET .set 1 ; storing
.else
OFFSET .set 0
.endif
.global _firlat
.text
_firlat:
;****************************************************************
; Data declarations: *
; *
; nsamps - number of input samples, controls outer loop *
; ova_flag - maximum scaling exponent *
; y_ptr - pointer to output buffer *
; h_ptr - pointer to coefficient vector *
; x_ptr - pointer to input/sample buffer *
; db_ptr - pointer to delay buffer *
; FRAME_SZ - size of local frame, # words reserved on *
; stack for local variables/temps *
; REG_SAVE_SZ - # words reserved onstack for saving regs *
; PARAM_OFFSET- offset from stack pointer to first func arg *
; *
; WARNING !!!! WARNING !!!! WARNING !!!! *
; To maintain compatability with TI TMS320C54x C compiler *
; the stack must be maintained at even length therefore: *
; OFFSET + RAME_SZ + REG_SAVE_SZ must be EVEN *
;**************************************************************** ;
REG_SAVE_SZ .set 1 ; for temp
PARAM_OFFSET .set REG_SAVE_SZ
.asg *sp(0), SAVE_AR1
.asg *sp(1), SAVE_AR6
.asg *sp(2), SAVE_AR7
.asg *sp(5), tmp
.asg *sp(6 + OFFSET), RETURN_ADDR
.asg *sp(7 + OFFSET), k ; remember that x is in the accumulator
.asg *sp(8 + OFFSET), f
.asg *sp(9 + OFFSET), d
.asg *sp(10 + OFFSET), nx
.asg *sp(11 + OFFSET), nk
.asg AR1, numCoeffs
.asg AR2, k_ptr
.asg AR3, d_ptr
.asg AR4, temp
.asg AR5, input
.asg AR6, output
.asg AR7, numInput
.asg A, gout
.asg B, fout
;****************************************************************************;
; 1. Save contents of AR1 ;
; 2. Save contents of AR6 ;
; 3. Save contents of AR7 ;
; 4. Establish local frame ;
; 5. Set sign extenions mode (SXM) ;
; 6. Set FRCT bit: ;
; Setting FRCT bit places target in arithmetic mode that is incompatible ;
; with the TI TMS320C54x C Compiler. THis bit must be restored prior to ;
; return from this routine.
;****************************************************************************;
FRAME #-REG_SAVE_SZ ; 1 cycle
PSHM AR1 ; 1 cycle
PSHM AR6 ; 1 cycle
PSHM AR7 ; 1 cycle
PSHM ST0 ; 1 cycle
PSHM ST1 ; 1 cycle
RSBX OVA ; 1 cycle
RSBX OVB ; 1 cycle
SSBX SXM ; 1 cycle
SSBX FRCT ; 1 cycle ; 6 c total
;**************************************************************;
; Copy arguments to their local locations as necessary *
;**************************************************************
MVDK nx, numInput ; 2 cycles
MVDK d, d_ptr ; 2 cycles
STLM A, input ; 1 cycles
MVDK k, k_ptr ; 2 cycles
MVDK f, output ; 2 cycles ; 15 c total
;**************************************************************
; Store 0 to AR0, to use as circular addressing offset *
;**************************************************************
STM #1, AR0 ; 2 cycles
;**************************************************************
; Store length of coefficient vector/delay buffer in BK *
; register; load value into Accumulator A *
;**************************************************************
MVDK nk, BK ; 2 cycle
LD nk, A ; 1 cycle
;***************************************************************
; Set outer loop count by subtracting 2 from Accumulator A and *
; storing the value into numCoeffs and into block repeat count *
; register *
;***************************************************************
SUB #2, A ; 2 cycles
STLM A, numCoeffs ; 1 cycle
MVDM numCoeffs, BRC ; 2 cycles ; 25 c total
;***************************************************************
; Set inner loop count by sutracting one from numInput *
;***************************************************************
MAR *numInput- ; 1 cycle
;****************************************************************************;
; Store the location of temperary buffer into temp auxiliary register ;
;****************************************************************************;
LDM SP, A
ADD #3, A
STLM A, temp
nop ; 4 cycles ; 30 c total
;**************************************************************
; Begin outer loop on # samples *
;**************************************************************
loop LD *input+, 16, A ; 1 cycle
STH A, *temp ; 1 cycle
LD #0, 16, B ; 2 cycle
STH B, *d_ptr ; 1 cycle
b mloop ; 4 cycles
loopo LD *input-, 16, A ; 1 cycle
STH A, *temp ; 1 cycle
LD *input+, 16, B ; 1 cycle
STH B, *d_ptr ; 1 cycle
MAR *input+ ; 1 cycle
mloop RPTBD endloopi -1 ; 2 cycles ; 14 * numInput
MAC *k_ptr+0%, *d_ptr+0%, A ; 1 cycle
ST A, *temp
|| MAC *temp, B ; 1 cycle
loopi MAC *k_ptr+0%, *d_ptr, A ; 1 cycle
ST B, *d_ptr
|| LD *d_ptr+0%, B ; 1 cycle
; 3 * numCoeffs
ST A, *temp
|| MAC *temp, B ; 1 cycle
endloopi STH A, *output+ ; 1 cycle
end2 BANZD loopo, *numInput- ; 2 cycles
MVDM numCoeffs, BRC ; 2 cycles
;****************************************************************************;
; 1. Reset FRCT bit to restore normal C operating environment
; 2. Return overflow condition, OVA, in accumulator A *
; 3. Restore stack to previous value, FRAME, etc.. *
;**************************************************************
RETURN:
LD #0, A ; 1 cycles
XC 1, AOV ; 1 cycle
LD #1, A ; 1 cycles
POPM ST1 ; 1 cycle
POPM ST0 ; 1 cycle
POPM AR7 ; 1 cycle
POPM AR6 ; 1 cycle
POPM AR1 ; 1 cycle
FRAME #REG_SAVE_SZ ; 1 cycle
.if __far_mode
FRETD ; 6 cycles
.else
RETD ; 5 cycles
.endif
nop ; 1 cycle
nop ; 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 + -