【发布时间】:2018-04-16 07:35:37
【问题描述】:
我有一个代码块,它是用 C 语言为 IAR C/C++ 编译器编写的。
__no_init uint8_t u8ramPhysStart_startUp @ 0x20000000;
__no_init uint8_t u8ramPhysEnd_startUp @ 0x2002FFFF;
__no_init uint8_t u8ramTestStart_startUp @ 0x20004008;
__no_init uint8_t u8ramTestEnd_startUp @ 0x20008008;
#define START_ASM (&u8ramPhysStart_startUp)
#define RAMSTART_STRTUP ((uint32_t)START_ASM)
我的目标是对其进行转换,或者更确切地说使其与 GCC 兼容。为此,我将上面的代码重写为:
unsigned char u8ramPhysStart_startUp __asm("@ 0x20000000");
unsigned char u8ramPhysEnd_startUp __asm("@ 0x2002FFFF");
unsigned char u8ramTestStart_startUp __asm("@ 0x20004008");
unsigned char u8ramTestEnd_startUp __asm("@ 0x20008008");
但编译后出现以下错误:
C:\Users\Pc\AppData\Local\Temp\ccyuCWQT.s: Assembler messages:
C:\Users\Pc\AppData\Local\Temp\ccyuCWQT.s:971: Error: expected symbol name
C:\Users\Pc\AppData\Local\Temp\ccyuCWQT.s:972: Error: expected symbol name
有人知道这是什么意思吗?
【问题讨论】:
-
语法不正确,不能像这样在同一行混用 ASM 和 C。强制地址:您可以使用属性部分 + 链接器脚本(NOLOAD 使部分初始化),或者如果您想要 GCC 和 IAR 兼容,请查看此处:stackoverflow.com/questions/4067811/…
-
感谢您的回答。现在使用
int *u8ramPhysStart_startUp = (int*)0x20000000;代替unsigned char u8ramPhysStart_startUp __asm("@ 0x20000000");它可以编译。 -
符号有什么作用?它们只是要在启动代码中使用的部分的开始和结束地址吗?