public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] opcodes/i386: use '; ' as comment character for intel style disassembly
Date: Mon, 29 Aug 2022 11:24:03 -0700	[thread overview]
Message-ID: <CAMe9rOo97Ck0DhyG+OAogTmimx5s2MBXfxBOporU1KTzx4bmSA@mail.gmail.com> (raw)
In-Reply-To: <20220827151845.1583899-1-aburgess@redhat.com>

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.


-- 
H.J.

  parent reply	other threads:[~2022-08-29 18:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-27 15:18 [PATCH] opcodes/i386: use ';' " Andrew Burgess
2022-08-27 15:18 ` [PATCH] opcodes/i386: use '; ' " Andrew Burgess
2022-08-29 18:24 ` H.J. Lu [this message]
2022-08-30  8:39   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMe9rOo97Ck0DhyG+OAogTmimx5s2MBXfxBOporU1KTzx4bmSA@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).