我正在尝试使用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'
答案 0 :(得分:1)
其他人指出,LOOP
是 C 宏。由于它没有参数或条件,因此很容易用gas
宏替换。
.macro 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
.endm
此后它的行为与#define
相同,但需要注意的是每行只允许一个。 ARM汇编程序允许在一行上有多个操作码(据我所知)。
您可以使用.rept
重复该宏。
.rept 2048
LOOP
.endr