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

📄 cfir.asm

📁 CCS3.3自带的TI 5400系列DSP的dsplib文件。文档说明可以在TI公司网站上下载。
💻 ASM
字号:
;***********************************************************
; Version 2.20.01                                           
;***********************************************************
;****************************************************************
;  Function:	cfir.asm
;  Description: complex fir
;
;  Copyright Texas instruments Inc, 1998
;----------------------------------------------------------------
;  Revision History:
;  1.00,  K. Baldwin. 8/31/98 - Original release.
;**************************************************************** 

	.mmregs
	.global _cfir
_cfir

; Far-mode adjustment

         .if __far_mode
OFFSET   .set  2
FRAME_SZ .set 1
         .else
OFFSET   .set  1
FRAME_SZ .set 2
         .endif

REG_SAVE_SZ    .set 5

PARAM_OFFSET   .set FRAME_SZ + REG_SAVE_SZ + OFFSET 


        .asg    0, n_macs
        .asg    0 + FRAME_SZ, SAVE_AR1
        .asg    1 + FRAME_SZ, SAVE_AR6
        .asg    2 + FRAME_SZ, SAVE_AR7
        .asg    0 + REG_SAVE_SZ + FRAME_SZ, RETURN_ADDR
        .asg    0 + PARAM_OFFSET, h
        .asg    1 + PARAM_OFFSET, r
        .asg    2 + PARAM_OFFSET, db
        .asg    3 + PARAM_OFFSET, nh
        .asg    4 + PARAM_OFFSET, nx
      
	
	

        .asg    AR0, inc
        .asg    AR1, nsamps
	.asg	AR2, h_real_ptr
	.asg	AR3, h_imag_ptr
	.asg	AR4, db_real_ptr
	.asg	AR5, db_imag_ptr
        .asg    AR6, r_ptr
        .asg    AR7, x_ptr


;
; Save contents of AR1                                    
; And establish local frame                               
; Set sign extension mode                                 
; Set FRCT bit:                                           
;
;----------------------------------------------------------------

        PSHM    AR7                             ; 1 cycle
        PSHM    AR6                             ; 1 cycle
        PSHM    AR1                             ; 1 cycle
        PSHM    ST0                                 ; 1 cycle
        PSHM    ST1                                 ; 1 cycle
        RSBX    OVA                                 ; 1 cycle
        RSBX    OVB                                 ; 1 cycle
                                      
        FRAME   #-FRAME_SZ                      ; 1 cycle
 

        SSBX	SXM                             ; 1 cycle
        SSBX    FRCT                            ; 1 cycle

;
; Copy arguments to their local locations as necessary        
;----------------------------------------------------------------

        STLM    A, x_ptr                            ; 1 cycle
	MVDK	*sp(r), r_ptr	  	            ; 2 cycles
	MVDK	*sp(db), db_real_ptr                ; 2 cycles
	MVDK	*sp(h), h_real_ptr                  ; 2 cycles
        MVMM    h_real_ptr, h_imag_ptr              ; 1 cycle
        LD      *db_real_ptr, B                     ; 1 cycle
        STLM    B, db_real_ptr                      ; 1 cycle
      
        MVMM    h_real_ptr, h_imag_ptr              ; 1 cycle
  
        
        MVDK    *sp(nx), nsamps                     ; 2 cycles
        MVMM    db_real_ptr, db_imag_ptr            ; 1 cycle
 

;
; Set outer loop count by subtracting 1 from nsamps and      
; storing into block repeat count register                   
;----------------------------------------------------------------
        LD     *sp(nh), A                           ; 1 cycle
        LD     A, 1, B                              ; 1 cycle
        STLM   B, BK                                ; 1 cycle
        SUB    #2, A                                ; 2 cyles
        STL    A, *sp(n_macs)                       ; 1 cycle
    

;
; Store increment for circular addressing in AR0                  
;----------------------------------------------------------------

        LD      #2, B                           ; 1 cycle
        STLM    B, AR0                          ; 2 cycles

;
; Adjust pointers to imaginary part of data and coefficients  
;----------------------------------------------------------------

       MAR     *db_imag_ptr+                       ; 1 cycle
       MAR     *h_imag_ptr+                        ; 1 cycle
       MAR     *nsamps-                            ; 1 cycle
     
;
; Begin outer loop on # samples                               
;----------------------------------------------------------------

L1:  	
                                
;
; Zero the accumulator before calculating next sum.          
; Move next input sample into delay buffer                   
;----------------------------------------------------------------

        MVDK    *sp(n_macs), BRC                       ; 2 cycles
        LD      *x_ptr+, A                             ; 1 cycle
        STL     A, *db_real_ptr                        ; 1 cycle

        LD      *x_ptr+ , A                            ; 1 cycle
        STL     A, *db_imag_ptr                        ; 1 cycle

        RPTBD   MAC_LOOP-1                             ; 2 cycles
        MPY      *h_real_ptr, *db_real_ptr, A          ; 1 cycle
        MPY      *h_real_ptr+0%, *db_imag_ptr, B       ; 1 cycle
	
;
; Sum h * x for next y value                                 
;----------------------------------------------------------------  


        MAS      *h_imag_ptr, *db_imag_ptr+0%, A       ; 1 cycle
        MAC      *h_imag_ptr+0%, *db_real_ptr+0%, B    ; 1 cycle
        MAC      *h_real_ptr, *db_real_ptr, A          ; 1 cycle
        MAC      *h_real_ptr+0%, *db_imag_ptr, B       ; 1 cycle
    
MAC_LOOP:
        MASR     *h_imag_ptr, *db_imag_ptr, A          ; 1 cycle
        MACR     *h_imag_ptr+0%, *db_real_ptr, B       ; 1 cycle
      
;
; Store results and repeat for next sample                   
;----------------------------------------------------------------

        BANZD    L1, *nsamps-                            ; 3 cycles
        STH      A, *r_ptr+                              ; 1 cycle
        STH      B, *r_ptr+                              ; 1 cycle                       

;
; Reset FRCT bit to restore normal C operating environment 
; Return overflow condition, OVA, in accumulator A         
; Restore stack to previous value, FRAME, etc..            
;----------------------------------------------------------------

RETURN:


        LDM      db_real_ptr, B                           ; 1 cycle
        MVDK     *sp(db), db_real_ptr                     ; 2 cycles
   
        LD       #0, A                                    ; 1 cycle
        XC       1, AOV                                   ; 1 cycle
        LD       #1, 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    AR1                                       ; 1 cycle
        POPM    AR6                                       ; 1 cycle
        POPM    AR7                                       ; 1 cycle

        .if __far_mode
           FRETD                                          ; 4 cycles
        .else
	   RETD                                           ; 3 cycles
        .endif
        NOP                                               ; delay slot 1 cycle
        STL      B, *db_real_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 + -