GNU汇编器错误:Intel语法代码,曾在2007年可用

3

我终于开始重拾我的colorforth项目了,几年前由于binutils的更新导致所有源代码失效而放弃了它。这里有一个示例来说明正在发生的事情:

jcomeau@aspire:~$ cat /tmp/test.as
    .intel_syntax
    .arch i386
    .code32
    mov eax,[foo + eax*4]
    lea    ecx,[ecx*4+0x9e0]
    mov    edx,DWORD PTR [edi*4-0x4]
    jmp    DWORD PTR [ecx*4+0x12cc]
    lea    edx,[ecx+edx*1]

第一条非指令行来自手册中的示例:https://sourceware.org/binutils/docs/as/i386_002dMemory.html#i386_002dMemory,其余部分来自带有--disassembler-options=intel标志的objdump反汇编。每一条都无法汇编:

jcomeau@aspire:~$ as /tmp/test.as
/tmp/test.as: Assembler messages:
/tmp/test.as:4: Error: too many memory references for `mov'
/tmp/test.as:5: Error: too many memory references for `lea'
/tmp/test.as:6: Error: too many memory references for `mov'
/tmp/test.as:8: Error: too many memory references for `lea'
/tmp/test.as:7: Error: invalid operands (*UND* and *ABS* sections) for `*'

整晚我一直在谷歌搜索,但没有找到任何结果。我确定我做错了什么,但是我真的搞不清楚问题出在哪里。我已经apt-get source binutils了,但不知道从哪里开始查找。

jcomeau@aspire:~$ as --version
GNU assembler (GNU Binutils for Debian) 2.25.90.20151209
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-linux-gnu'.

那么,重新开始使用 gas 的魔法咒语是什么?


尝试使用.intel_syntax noprefix。如果您不使用noprefix,GAS仍然希望寄存器名称以(百分号)为前缀,这似乎是您问题的原因。 - Michael Petch
1
哦,太简单了。请将其作为答案放入,我会接受它。谢谢你。 - jcomeau_ictx
1个回答

5

使用GNU汇编器时,如果使用.intel_syntax指令,您需要使用noprefix选项来强制AS不要求在寄存器名称前加上%(类似于AT&T语法)。建议您使用以下命令:

.intel_syntax noprefix

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接