24小时热门版块排行榜    

查看: 1175  |  回复: 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的回帖

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的回帖

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的回帖
相关版块跳转 我要订阅楼主 jianchaoyv 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 深圳大学硕士招生(2026秋,传感器方向,仅录取第一志愿) +4 xujiaoszu 2026-03-11 8/400 2026-03-16 09:45 by xujiaoszu
[考研] 290求调剂 +5 孔志浩 2026-03-12 10/500 2026-03-16 09:01 by 余晖&
[考研] 321求调剂 +4 大米饭! 2026-03-15 4/200 2026-03-16 08:41 by Linda Hu
[考研] 梁成伟老师课题组欢迎你的加入 +6 一鸭鸭哟 2026-03-14 7/350 2026-03-15 22:12 by Winj1e
[文学芳草园] 伙伴们,祝我生日快乐吧 +15 myrtle 2026-03-10 24/1200 2026-03-15 21:16 by 苏州_逗号
[考研] 297一志愿上交085600求调剂 +5 指尖八千里 2026-03-14 5/250 2026-03-14 17:26 by a不易
[考研] 求调剂 +3 清风问长安 2026-03-09 3/150 2026-03-14 02:15 by JourneyLucky
[考研] 2026考研调剂+本科延边大学+山东大学+生物化学与分子生物学+有项目经验 +3 ccdsscjy 2026-03-09 6/300 2026-03-14 02:14 by JourneyLucky
[考研] 一志愿湖师大化学289求调剂 +6 XMCMM3.14159 2026-03-10 6/300 2026-03-14 00:28 by JourneyLucky
[考研] 材料371求调剂 +9 鳄鱼? 2026-03-11 11/550 2026-03-13 22:53 by JourneyLucky
[考研] 337一志愿华南理工0805材料求调剂 +7 mysdl 2026-03-11 9/450 2026-03-13 22:43 by JourneyLucky
[考研] 085600调剂 +5 漾漾123sun 2026-03-12 5/250 2026-03-13 22:06 by 星空星月
[考研] 求b区学校调剂 +3 周56 2026-03-11 3/150 2026-03-13 16:20 by JourneyLucky
[考研] 290求调剂 +7 ADT 2026-03-12 7/350 2026-03-13 15:17 by JourneyLucky
[考研] 285求调剂 +4 ytter 2026-03-12 4/200 2026-03-13 14:48 by jxchenghu
[考研] 0703一志愿211 285分求调剂 +4 ly3471z 2026-03-13 4/200 2026-03-13 13:00 by JourneyLucky
[考研] 289求调剂 +3 李政莹 2026-03-12 3/150 2026-03-13 11:02 by 求调剂zz
[考博] 26读博 +4 Rui135246 2026-03-12 10/500 2026-03-13 07:15 by gaobiao
[考研] 290求调剂 +3 柯淮然 2026-03-10 8/400 2026-03-11 13:48 by 柯淮然
[考研] 求调剂材料专硕293 +6 段_(:з」∠)_ 2026-03-10 6/300 2026-03-10 18:22 by ms629
信息提示
请填处理意见