This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

有一个关于MemCopy()的疑惑



   经过TI的指导,大致已经明白这个函数的作用,以及CODESECTION的使用方法。

   但是一直有一个疑惑:

      ramfuncs             : LOAD  = FLASHD,     //表示从FLASHD中加载程序

                                    RUN  = RAML0,     //表示从RAML0中运行程序

                                    LOAD_START(_RamfuncsLoadStart), //   

                                    LOAD_END(_RamfuncsLoadEnd),  //            

                                    RUN_START(_RamfuncsRunStart),  //        

                                   PAGE = 0

在MemCopy时,RamfuncsLoadStart是拷贝起始地址,RamfuncsLoadEnd是结束地址,RamfuncsRunStart是程序运行起始地址

但是在主程序中就只是声明了三个extern 的extern Uint16 RamfuncsLoadStart; extern Uint16 RamfuncsLoadEnd; extern Uint16 RamfuncsRunStart;

又没有指向RAML0的特定地址,编译器是怎么确定具体的地址呢?

比如定义了RamfuncsLoadStart这个变量,又没指定值,执行MemCopy时,编译器就知道从哪里开始搬移程序了?

而且"_RamfuncsLoadStart"与“RamfuncsLoadStart”  不同的是一个多了一个下划线,编译器判定它们是一个东西??

实在没想明白……

求教了

 

  • Lzh,

    其实这三个变量在cmd中的ramfunc已经定义了,编译器在进行编译的时候,就会对它们进行赋值,因为只有经过编译,才能知道loadStart和loadend的地址。

    所以在main文件中只要声明外部变量就行了。

    另外下划线是cmd的语法,在外部源文件要使用这个变量,只要将下划线去掉就可以了。

    Eric