【发布时间】:2013-07-09 16:37:18
【问题描述】:
我正在尝试使用icachetest,其中有一个名为icache.s 的文件包含:
#define LOOP \
subs r2, r2, #1 ; \
mov r0, r0 ; \
mov r0, r0 ; \
mov r0, r0 ; \
mov r0, r0 ; \
mov r0, r0 ; \
beq end_loop ; \
mov r0, r0 ; \
我正在使用arm-eabi-as 编译这个项目,但我得到了这个错误:
AS icache.S
icache.S: Assembler messages:
icache.S:16: Error: junk at end of line, first unrecognized character is `\'
icache.S:17: Error: junk at end of line, first unrecognized character is `\'
icache.S:18: Error: junk at end of line, first unrecognized character is `\'
icache.S:19: Error: junk at end of line, first unrecognized character is `\'
icache.S:20: Error: junk at end of line, first unrecognized character is `\'
icache.S:21: Error: junk at end of line, first unrecognized character is `\'
icache.S:22: Error: junk at end of line, first unrecognized character is `\'
icache.S:23: Error: junk at end of line, first unrecognized character is `\'
icache.S:52: Error: bad instruction `loop LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP'
icache.S:53: Error: bad instruction `loop LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP'
icache.S:54: Error: bad instruction `loop LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP LOOP'
【问题讨论】:
-
您不应该使用
as- 只需要使用gcc以便调用预处理器,例如gcc -Wall icache.S .... -
as 是汇编程序,干净的汇编将与 as 一起正常组装。如果您在程序集中尝试使用 C 代码进行一些混合语言的操作,那么您需要在 gcc 调用之前使用 C 预处理器。基本上你不会在 asm 中使用定义,而是使用宏。
-
@PaulR 将
gcc -Wall运行为as好吗? -
是的,这就是重点——如果您使用 gcc 作为驱动程序,那么它会负责预处理(以及其他各种事情)并将预处理的 asm 源传递给
as。