关于代码在RAM执行的疑问

2019-03-23 22:20发布

这些天在尝试将28335的代码从FLASH搬移到RAM执行,通过反复执行一次正弦计算来间接验证搬移是否成功,在FLASH中跑代码的时候,计算一次大概用时5US,刚测试了下,时间缩短至0.5US的样子,然后我断电在上电,差不多还是0.5US的计算时间,是不是就能间接证明我的代码搬移是成功了呢?
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
asdmaill
1楼-- · 2019-03-24 01:06
另外,在如下代码中,我用分号屏蔽的那些全局变量是什么作用,我不屏蔽的话,要报错。这个段拷贝汇编代码是代码搬移必须用到的
;############################################################################
;
; FILE:   DSP28xxx_SectionCopy_nonBIOS.asm
;
; DESCRIPTION:  Provides functionality for copying intialized sections from
;                                flash to ram at runtime before entering the _c_int00 startup
;                                routine
;############################################################################
; Author: Tim Love
; Release Date: March 2008       
;############################################################################
        .ref _c_int00
        .global copy_sections
        ;.global _cinit_loadstart, _cinit_runstart, _cinit_size
        ;.global _const_loadstart, _const_runstart, _const_size
        ;.global _econst_loadstart, _econst_runstart, _econst_size
        ;.global _pinit_loadstart, _pinit_runstart, _pinit_size
        ;.global _switch_loadstart, _switch_runstart, _switch_size
        .global _text_loadstart, _text_runstart, _text_size

***********************************************************************
* Function: copy_sections
*
* Description: Copies initialized sections from flash to ram
***********************************************************************

        .sect "copysections"

copy_sections:


        ;MOVL XAR5,#_cinit_size                                ; Store Section Size in XAR5
        ;MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        ;MOVL XAR6,#_cinit_loadstart                        ; Store Load Starting Address in XAR6
    ;MOVL XAR7,#_cinit_runstart                        ; Store Run Address in XAR7
    ;LCR  copy                                                        ; Branch to Copy

        ;MOVL XAR5,#_const_size                                ; Store Section Size in XAR5
        ;MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        ;MOVL XAR6,#_const_loadstart                        ; Store Load Starting Address in XAR6
    ;MOVL XAR7,#_const_runstart                        ; Store Run Address in XAR7
    ;LCR  copy                                                        ; Branch to Copy

        ;MOVL XAR5,#_econst_size                                ; Store Section Size in XAR5
        ;MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        ;MOVL XAR6,#_econst_loadstart                ; Store Load Starting Address in XAR6
    ;MOVL XAR7,#_econst_runstart                        ; Store Run Address in XAR7
    ;LCR  copy                                                        ; Branch to Copy

        ;MOVL XAR5,#_pinit_size                                ; Store Section Size in XAR5
        ;MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        ;MOVL XAR6,#_pinit_loadstart                        ; Store Load Starting Address in XAR6
    ;MOVL XAR7,#_pinit_runstart                        ; Store Run Address in XAR7
    ;LCR  copy                                                        ; Branch to Copy

        ;MOVL XAR5,#_switch_size                                ; Store Section Size in XAR5
        ;MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        ;MOVL XAR6,#_switch_loadstart                ; Store Load Starting Address in XAR6
    ;MOVL XAR7,#_switch_runstart                        ; Store Run Address in XAR7
    ;LCR  copy                                                        ; Branch to Copy

        MOVL XAR5,#_text_size                                ; Store Section Size in XAR5
        MOVL ACC,@XAR5                                                ; Move Section Size to ACC
        MOVL XAR6,#_text_loadstart                        ; Store Load Starting Address in XAR6
    MOVL XAR7,#_text_runstart                        ; Store Run Address in XAR7
    LCR  copy                                                        ; Branch to Copy

          
          LB _c_int00                                                         ; Branch to start of boot.asm in RTS library

copy:       
        B return,EQ                                                        ; Return if ACC is Zero (No section to copy)

        SUBB ACC,#1

    RPT AL                                                                ; Copy Section From Load Address to
    || PWRITE  *XAR7, *XAR6++                        ; Run Address

return:
        LRETR                                                                ; Return

        .end
       

一周热门 更多>

相关问题

    相关文章