首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]初学DSP(C54XX),求高手指点下迷津:C调用汇编子函数参数是如何传递的?以

[求助]初学DSP(C54XX),求高手指点下迷津:C调用汇编子函数参数是如何传递的?以

初学DSPC54XX),求高手指点下迷津:C调用汇编子函数参数是如何传递的?

这是CCS里的库函数FIR,有很多地方都不明白,求高手指点迷津。

short fir(short *x, short *h, short *r, short **d, unsigned short nh, unsigned short nx)

x:输入数据指针

h:抽头系数指针

r:输出数据指针

d:指向延迟缓冲区首地址的指针

nh:滤波抽头个数

nx:输入数据个数

//以上应该没有弄错吧?

 

 

;***********************************************************

; Version 2.20.01                                          

;***********************************************************

;****************************************************************

;  Function:   fir

;  Description: delayed buffer finite impulse response filter

;  Copyright Texas instruments Inc, 1998

;----------------------------------------------------------------

;  Revision History:

;  1.00, Karen Baldwin 8/31/98. Original Beta Release.

;****************************************************************

.mmregs

; Far-mode adjustment

; -------------------

         .if __far_mode

OFFSET                    .set  2    

         .else

OFFSET                    .set  1          

         .endif

//OFFSET是什么的长度?返回地址占用堆栈空间长度?

FRAME_SZ             .set 1   

 // FRAME_SZ是什么的长度?局部变量量是哪个?

REG_SAVE_SZ          .set 2 

 // REG_SAVE_SZ是什么的长度?ST0ST1

PARAM_OFFSET        .set  FRAME_SZ + REG_SAVE_SZ + OFFSET

[此贴子已经被作者于2006-11-27 23:34:54编辑过]

; Register usage

; --------------

        .asg    0 + FRAME_SZ, SAVE_AR1

        .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        0, nc

              .asg        AR2, r_ptr

              .asg        AR3, h_ptr

.asg        AR4, x_ptr

.asg        AR5, db_ptr

              .asg        BRC, rptb_cnt

;**************************************************************************

       .global _fir

_fir

        PSHM    ST0                                     ; 1 cycle

        PSHM    ST1                                     ; 1 cycle

        RSBX    OVA                                     ; 1 cycle

        RSBX    OVB                                     ; 1 cycle

; Save contents of AR1             //哪个指令保存AR1的内容?

                               // 还是指保存的ST0中的ARP1                  

; And establish local frame                              

; Set sign extension mode                                

; Set FRCT bit:            

;----------------------------------------------------------------

              FRAME   #-(FRAME_SZ)                                              ; 1 cycle

// 在堆栈中留出FRAME_SZ长度空间用来保存哪个变量?

//此时堆栈情况如何?

        SSBX      SXM                                       ; 1 cycle

        SSBX    FRCT                                       ; 1 cycle

[此贴子已经被作者于2006-11-27 23:26:48编辑过]

; Copy arguments to their local locations as necessary       

;----------------------------------------------------------------

        STLM    A, x_ptr                                   ; 1 cycle

        MVDK   *sp(h), h_ptr                                ; 2 cycles

              MVDK   *sp(r), r_ptr                                 ; 2 cycles

              MVDK   *sp(db), db_ptr                              ; 2 cycles

//此时SP(0)是什么?

; Set outer loop count by subtracting 1 from nsamps and     

; storing into block repeat count register                  

;----------------------------------------------------------------

        LD     *sp(nx), A                                      ; 1 cycle

        SUB     #1, A                                         ; 2 cycles

        STLM    A, rptb_cnt                                   ; 1 cycle

; Set pointer to delay buffer                                

;----------------------------------------------------------------

        LD      *db_ptr, A                                     ; 1 cycle

        STLM    A, db_ptr                                    ; 1 cycle

; Store length of coefficient vector/ delay buffer in BK    

; register                                                  

;----------------------------------------------------------------

        LD      *sp(nh), A                                      ; 1 cycle

        STLM    A, BK                                       ; 1 cycle

//[BK ]=延迟缓冲区长度

              SUB
    
       #3, A                                                             ; 2 cycles

              STL        A, *sp(nc)                                                     ; 1 cycle

[此贴子已经被作者于2006-11-27 23:31:48编辑过]

; Begin outer loop on # samples                              

;----------------------------------------------------------------

_start:

          RPTBD END_LOOP - 1                                         ; 2 cycles             

//块循环[db_ptr]+1  

; Store 0 to AR0, to use as circular addressing offset      

;----------------------------------------------------------------

              STM       #1, AR0                 ; delay slot              ; 2 cycles

; Zero the accumulator before calculating next sum.         

; Move next input sample into delay buffer                   

;----------------------------------------------------------------

         MVDD    *x_ptr+, *db_ptr                                         ; 1 cycles

; Sum h * x for next y value                                

;----------------------------------------------------------------

              MPY       *h_ptr+0%, *db_ptr+0%, A                            ; 1 cycle

              RPT
    
*sp(nc)                        ; 2 cycle

        //重复执行下一条指令*sp(nc)[BK ]-3+1次。

              MAC       *h_ptr+0% , *db_ptr+0%, A                                ; 1 cycle * ncoeffs-2

              MACR    *h_ptr+0% , *db_ptr, A                                 ; 1 cycle

              //加上首尾各一次乘累加,总共[BK ]次。

; Store result                                                   

;----------------------------------------------------------------

              STH
    
A, *r_ptr+                         ; 1 cycle

END_LOOP:

_end:

[此贴子已经被作者于2006-11-27 23:32:28编辑过]

; 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_ptr, B                                ; 1 cycle

                                   //将延迟缓冲区最后一个数据x(n-k+1)的地址传到B

//B= &x(n-k+1)?

//在这里有什么用处?

        MVDK    *sp(db), db_ptr                          ; 2 cycles

                                   //将延迟缓冲区首地址传到db_ptr中?

//*db_ptr=x(n)?

//在这里有什么用处?

        LD        #0, A                                    ; 1 cycle

        XC        1, AOV                                   ; 1 cycle

        LD        #1, A                                    ; 1 cycle

                  //溢出返回1                                                          

[此贴子已经被作者于2006-11-27 23:33:04编辑过]

              FRAME  #(FRAME_SZ)                                                      ; 1 cycle

        POPM     ST1                                             ; 1 cycle

        POPM     ST0                                             ; 1 cycle

        .if __far_mode

            FRETD                                                 ; 4 cycles

        .else

            RETD                                                  ; 3.0 cycles

        .endif

        NOP                                                 ; delay slot 1 cycle

              STL
    
B, *db_ptr                                                                    ; delay slot 1 cycle

                // 用延迟缓冲区最后的数据xn-k+1)的地址
   
覆盖xn)的数据?

                // x(n)=& x(n-k+1)

                //在这里有什么用处?

;END

;end of file. please do not remove. it is left here to ensure that no lines of code are removed by any editor

[此贴子已经被作者于2006-11-27 23:35:54编辑过]

返回列表