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

jco*_*ctx 3 x86 assembly gnu-assembler intel-syntax

我终于回到了我的 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]
Run Code Online (Sandbox Code Playgroud)

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

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 `*'
Run Code Online (Sandbox Code Playgroud)

我整个晚上都在谷歌上搜索,但没有运气。我确定我做错了什么,但如果我能弄清楚它是什么该死的。我有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'.
Run Code Online (Sandbox Code Playgroud)

那么gas再次烹饪的魔法咒语是什么?

Mic*_*tch 5

当使用带有.intel_syntax指令的GNU Assembler 时,您需要使用该noprefix选项来强制AS不需要%在注册名称前添加(百分号)(如 AT&T 语法)。您可能应该使用:

.intel_syntax noprefix
Run Code Online (Sandbox Code Playgroud)