0

我正在尝试使用icachetest,它有一个名为icache.scontains 的文件:

#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'
4

1 回答 1

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

此后它的行为与 a 相同#define,但需要注意的是每行只允许一个。ARM 汇编器确实允许一行中有多个操作码(据我所知)。

您可以使用.rept重复宏。

.rept 2048
   LOOP
.endr
于 2013-07-09T17:58:38.647 回答