?? fir_filters_asm.asm
字號:
;******************************************************************************
;* FILENAME *
;* FIR_filters_asm.asm *
;* *
;* DESCRIPTION *
;* Finite Impulse Response Filters using the TMS320C5416 DSK. *
;* Implemented in assembly language because C code versions are too slow *
;* *
;* Revision: 1.00 *
;* Author: Richard Sikora *
;* *
;*----------------------------------------------------------------------------*
;* HISTORY *
;* Revision: 1.00 *
;* 11th November 2002. Created by Richard Sikora from FIR_filters.c *
;* *
;*----------------------------------------------------------------------------*
;* *
;* The number of FIR filter elements is controlled by N *
;* *
;******************************************************************************
.mmregs
FP .set AR7
N .set 51
.sect ".text"
; First buffer of N = 51 elements
.global _buffer1
.bss _buffer1,51,0,0
; Second buffer of N = 51 elements
.global _buffer2
.bss _buffer2,N,0,0
; Third buffer of N = 51 elements
.global _buffer3
.bss _buffer3,N,0,0
; Fourth buffer of N = 51 elements
.global _buffer4
.bss _buffer4,N,0,0
; Give functions global scope to make them available to other functions
.sect ".text"
.global _FIR_filters_asm_initialize
.global _FIR_filter_asm
.global _FIR_filter_asm_2
.global _FIR_dual_filter_asm
.global _FIR_dual_filter_variable_asm
;******************************************************************************
;* FUNCTION DEF: _FIR_asm_initialize *
;******************************************************************************
;* *
;* Fill four buffers used for FIR filters with zeroes to prevent noise and *
;* clicks. *
;* *
;******************************************************************************
_FIR_filters_asm_initialize:
PSHM AR3 ; Temporary save AR3
STM #_buffer1, AR3 ; AR3 points to buffer1[0]
RPT #(N-1) ; N - 1 repeats
ST #0, *AR3+ ; Fill each element with zero
STM #_buffer2, AR3 ; AR3 points to buffer2[0]
RPT #(N-1) ; N - 1 repeats
ST #0, *AR3+ ; Fill each element with zero
STM #_buffer3, AR3 ; AR3 points to buffer3[0]
RPT #(N-1) ; N - 1 repeats
ST #0, *AR3+ ; Fill each element with zero
STM #_buffer4, AR3 ; AR3 points to buffer4[0]
RPT #(N-1) ; N - 1 repeats
ST #0, *AR3+ ; Fill each element with zero
POPM AR3 ; Restore AR3
FRET ; Far return
;******************************************************************************
;* FUNCTION DEF: _FIR_filter_asm *
;******************************************************************************
;* *
;* FIR filter for first channel. Can be used for high pass, low pass *
;* or other FIR filters. *
;* *
;******************************************************************************
_FIR_filter_asm:
PSHM ST0 ; Any flags set here no side-effects
PSHM ST1
PSHM AR3
PSHM AR4
SSBX OVM ; Prevent overflow
SSBX FRCT
FRAME #-1
STLM A,AR3 ; AR3 now points to _coefficients
; Start by shuffling values in buffer along and inserting new value at buffer[0]
STM #_buffer1+N-2, AR4 ; AR4 points to buffer[8]
RPT #(N-2) ; Shuffle all the values. # is important!
DELAY *AR4-
MVDK *SP(4+3),*(_buffer1) ; New input to beginning of buffer
STM #_buffer1, AR4 ; AR4 now points to buffer[0]
; Multiplications with accumulation
RPTZ A, #(N-2) ; Clear A then repeat 8 times
MAC *AR3+, *AR4+, A ; Multiply and accumulate in A
MACR *AR3+, *AR4+, A ; Round up the last one
SFTA A, -16, A ; Remove fractional part
; Ready to return output in Accumulator A
FRAME #1
POPM AR4
POPM AR3
POPM ST1
POPM ST0
FRET
;******************************************************************************
;* FUNCTION DEF: _FIR_filter_asm_2 *
;******************************************************************************
;* *
;* FIR filter for second channel. Can be used for high pass, low pass *
;* or other FIR filters. *
;* *
;******************************************************************************
_FIR_filter_asm_2:
PSHM ST0 ; Any flags set here no side-effects
PSHM ST1
PSHM AR3
PSHM AR4
SSBX OVM ; Prevent overflow
SSBX FRCT
FRAME #-1
STLM A,AR3 ; AR3 now points to _coefficients
; Start by shuffling values in buffer along and inserting new value at buffer[0]
STM #_buffer2+N-2, AR4 ; AR4 points to buffer[8]
RPT #(N-2) ; Shuffle all the values. # is important!
DELAY *AR4-
MVDK *SP(4+3),*(_buffer2) ; New input to beginning of buffer
STM #_buffer2, AR4 ; AR4 now points to buffer[0]
; Multiplications with accumulation
RPTZ A, #(N-2) ; Clear A then repeat 8 times
MAC *AR3+, *AR4+, A ; Multiply and accumulate in A
MACR *AR3+, *AR4+, A ; Round up the last one
SFTA A, -16, A ; Remove fractional part
; Ready to return output in Accumulator A
FRAME #1
POPM AR4
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -