[PATCH] opcodes/i386: use '; ' as comment character for intel style disassembly

H.J. Lu hjl.tools@gmail.com
Mon Aug 29 18:24:03 GMT 2022

On Sat, Aug 27, 2022 at 8:19 AM Andrew Burgess via Binutils
<binutils@sourceware.org> wrote:
> While working on a disassembly related GDB issue I was comparing the
> disassembly output for x86-64 in att mode and intel mode.
> I ended up trying to cut & paste some disassembly snippets from the
> disassembler, and feed the instructions back through the assembler.
> For the att style disassembly this worked fine, but for the intel
> style disassembly I ran into a problem as the '#' character, which is
> used for comments in i386-dis.c was not recognised by either of the
> intel style assemblers I have to handle (nasm and yasm).
> Searching online, every example I could find that has intel style
> assembly syntax, used ';' for the comment character, and indeed, when
> I switch '#' to ';', my same code assembled fine.

But, ';' marks the end of instructions for GNU assembler:

[hjl@gnu-efi-2 tmp]$ cat x.s
.intel_syntax noprefix
mov eax, edx; mov eax, edx;
[hjl@gnu-efi-2 tmp]$ gcc -c x.s
[hjl@gnu-efi-2 tmp]$ objdump -dw -Mintel x.o

x.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <.text>:
   0: 89 d0                mov    eax,edx
   2: 89 d0                mov    eax,edx
[hjl@gnu-efi-2 tmp]$

> In i386-dis.c we already have a bunch of characters that are
> customised based on the selected syntax, see open_char, close_char,
> separator_char, and scale_char.
> I propose to add comment_char to this list.  This will be '#' for att
> syntax, and ';' for intel syntax.
> I've updated the gas tests to account for this change.


More information about the Binutils mailing list