24小时热门版块排行榜    

查看: 1127  |  回复: 4
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

jianchaoyv

金虫 (小有名气)

[交流] 【求助】请帮忙看一个汇编函数

/***********************************************************************
* _DFT_Fundamental:  
*                                  calculate DFT transform for the fundamental waveform
*                                    this routine could be use to calculate the phase of fundamental waveform
*                                  which equals to atan(A(1)/B(1))
*
* Operation:
* F(1) = (1/N)* sum_n (f(n)*WN(n)), WN(n) = exp[-(j*2*pi*n)/N],
*         n in {0, 1,... , N-1},
* F(2) = (1/N)* sum_n (f(n)*WN(n)), WN(n) = exp[-(j*2*pi*n)/N],
*         n in {N, 1,... , 2*N-1},
*
* calculate:
*                        cycle 1 's DFT transform
*    and    cycle 2 's DFT transform
* Input:
*   w0 = number of source data per cycle       
*        w1 = ptr to source vector (srcCV)                ----- data should be stored in Y-DATA memory
*   w2 = ptr to output value
*        w3 = ptr to cos_sin table                       
*        w4 = COEFFS_IN_DATA, or memory program page with cos_sin table
*   w5 = calculate cycle number
* Return:
*         null
* result store in (w2) array, where
* (w2  ) = F(1).real
* (w2+1) = F(1).imag
* (w2+2) = F(2).real
* (w2+3) = F(2).imag
*
* System resources usage:
*        {w0..w7}        used, not restored
*        {w8..w13}        saved, used, restored
*         AccuA                used, not restored
*         AccuB                used, not restored
*         CORCON                saved, used, restored
*         PSVPAG                saved, used, restored (if factors in P memory)
*
* one loop stage usage.
* instruction cycle:
*                w0 * 4 +
* execution time under 30MIPS:
*        Design By:                                         Jemmey Huang  CADC
*        Last modification:                         Oct 8 / 2006
***********************************************************************/
_DFT_Fundamental:

        push.d        w8                                ; {w8,w9} to TOS
        push.d        w10                                ; {w10,w11} to TOS
        push.d        w12                                ; {w12,w13} to TOS

;............................................................................

        ; Prepare CORCON for fractional computation.
        push CORCON
        bset CORCON, #4                                        ;ACCSAT = 1, Set 9.31 mode
        bset CORCON, #6                                        ;ACCSAT = 1, Set 9.31 mode
        bset CORCON, #7                                        ;ACCSAT = 1, Set 9.31 mode

;............................................................................

        ; Prepare CORCON and PSVPAG for possible access of data
        ; located in program memory, using the PSV.
        push        PSVPAG;


        mov        #COEFFS_IN_DATA,w7                        ; w7 = COEFFS_IN_DATA
        psvaccess        w7                                        ; enable PSV bit in CORCON
        mov        w4,PSVPAG                                        ; load PSVPAG with program
                                                                        ; space page offset
                                                                        ; from here w4 can be used for other job

        mov w5, w9                                                ; cycle number store to w9

        mov w0, w7                                                ; data length = N
        dec w7, w7                                                ; N-1

        ; from here,
        ; w0 data length N
        ; w1 source data start address
        ; w2 return data start address
        ; w3 table start address for cosx
        ; w4 not use
        ; w5, w6 use by MAC
        ; w7 loop counter = N-1
        ; w8 X data pointer to the sin_cos table
        ; w9 cycle number
        ; w10 Y data pointer to the f(i)
        ; w11 not use
        ; w12 not use
        ; w13 not use

        mov w1, w11
_loop_cycls:
        mov w11, w10                                        ; source data begining address
        mov w3, w8                                                ; cos table begining address       
        clr A
        mov [w10++], w6                                        ; pre-fetch source data
        mov [w8++], w5                                        ; pre-fetch cos table
        repeat  w7
        mac w5*w6, a, [w8]+=2, w5, [w10]+=2, w6
        sac.r a, #5, [w2++]                                ; stored real value of cycle 1

        mov w11, w10                                        ; retrive source data begining address
        mov [w10++], w6                                        ; pre-fetch data f(1)
        clr A
        repeat w7                                                ; repeat N time
        mac w5*w6, a, [w8]+=2, w5, [w10]+=2, w6
        sac.r a, #5, [w2++]                                ; stored image value of cycle 1  >>20

        add w11, w0, w11
        add w11, w0, w11
        dec        w9, w9                                                ; w9--
        bra        gt,_loop_cycls                                ; if w0 > 0, do next stage
       

        ; Restore PSVPAG and CORCON.
        pop        PSVPAG
        pop        CORCON

        pop.d        w12                                ; {w12,w13} to TOS
        pop.d        w10                                ; {w10,w11} to TOS
        pop.d        w8                                ; {w8,w9} to TOS
        return
               
其中这部分:
        ; Prepare CORCON and PSVPAG for possible access of data
        ; located in program memory, using the PSV.
        push        PSVPAG;


        mov        #COEFFS_IN_DATA,w7                        ; w7 = COEFFS_IN_DATA
        psvaccess        w7                                        ; enable PSV bit in CORCON
        mov        w4,PSVPAG                                        ; load PSVPAG with program
                                                                        ; space page offset
                                                                        ; from here w4 can be used for other job
是什么意思?急求帮助!!!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

huycwork

金虫 (著名写手)


微尘、梦想(金币+1): 谢谢回复…… 2011-04-14 21:07:39
; Prepare CORCON and PSVPAG for possible access of data   ;这里就说明了CORCON和PSVPAG是两个状态寄存器
        ; located in program memory, using the PSV.                          ;设置程序状态,启用PSV位
        push        PSVPAG;                                                                       ;备份寄存器


        mov        #COEFFS_IN_DATA,w7                                               ; 赋值,COEFFS_IN_DATA是常量值
        psvaccess        w7                                                                          ; 打开CORCON寄存器中的PSV位
        mov        w4,PSVPAG                                                                    ; 为程序设置PSVPAG
============================================================================
上面是大体意思,具体而言,应该翻阅单片机手册以查看CORCON和PSVPAG这两个寄存器干嘛用的,因单片机的不同,功能也不尽相同
漩涡的中心有一块空地,空空的。
5楼2011-04-13 23:25:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 5 个回答

fengyu027

木虫 (正式写手)

你这个是一个什么程序啊 是反汇编出来的吗
坚持就是胜利!
2楼2010-08-23 16:01:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

hn911

金虫 (小有名气)


余泽成(金币+1):谢谢参与应助! 2010-09-10 16:16:25
这是计算基本波形的离散傅里叶转换
3楼2010-09-10 14:59:31
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

siqin123

新虫 (正式写手)


微尘、梦想(金币+1): 谢谢回复…… 2011-04-14 21:07:24
求与反正切函数等值的离散傅里叶变换
坚持是一种信仰,积累是一种智慧
4楼2011-01-14 21:05:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见