用于 2007 年的英特尔语法代码的 GNU 汇编程序错误

GNU assembler errors on intel syntax code that used to work in 2007

我终于回到了我的 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 反汇编。每一个都失败 assemble:

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 指令的 GNU 汇编程序时,您需要使用 noprefix 选项来强制 A​​S 不需要 %(百分号)作为注册名称的前缀(类似于 AT&T 语法)。您可能应该使用:

.intel_syntax noprefix