⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fir_filters_asm.asm

📁 TMS320C5416算法程序包。其中包括FFT
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;******************************************************************************
;* 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  

	.bss	_buffer1,51,0,0

; Second buffer of N = 51 elements  

    .bss    _buffer2,N,0,0

; Third buffer of N = 51 elements  

    .bss    _buffer3,N,0,0
    
; Fourth buffer of N = 51 elements  

    .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                   ; Keep original values of flags
	    PSHM      ST1
        PSHM      AR3                   ; Keep original values of registers
        PSHM      AR4
        
        SSBX      OVM                   ; Prevent overflow 
        SSBX      FRCT                  ; Extra shift for multiplications
        SSBX      SXM                   ; Turn on sign-extension mode
        
        FRAME     #-1                   ; Create stack frame  
        
        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 N - 2 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                    ; Restore registers
        POPM      AR3
        POPM      ST1                    ; Restore flags
        POPM      ST0                    

        FRET                             ; Far return 


;******************************************************************************
;* 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                   ; Keep original values of flags
	    PSHM      ST1
        PSHM      AR3                   ; Keep original values of registers
        PSHM      AR4

        SSBX      OVM                   ; Prevent overflow 
        SSBX      FRCT                  ; Extra shift for multiplications
        SSBX      SXM                   ; Turn on sign-extension mode

        FRAME     #-1                   ; Create stack frame

        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                    ; Restore registers
        POPM      AR3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -