public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: "H. J. Lu" <hjl@lucon.org>
Cc: "Allan B. Cruse" <cruse@cs.usfca.edu>, binutils@sources.redhat.com
Subject: Re: PATCH: Fix i386 disassembler with index == 0x4 in SIB (Re: objdump bug-report)
Date: Thu, 13 Jan 2005 03:44:00 -0000	[thread overview]
Message-ID: <20050113034440.GG30985@bubble.modra.org> (raw)
In-Reply-To: <20050112191052.GA12463@lucon.org>

On Wed, Jan 12, 2005 at 11:10:52AM -0800, H. J. Lu wrote:
> > 	.byte	0x8B, 0x04, 0x63	# effect is: movl (%ebx), %eax	
[snip]
> >  8048081:	8b 04 63             	mov    (%ebx,2),%eax

I don't agree that this is a problem.  In fact, I think that this
disassembly is more accurate than "mov (%ebx),%eax".  Note that gas
accepts "mov (%ebx,2),%eax" giving
Warning: scale factor of 2 without an index register

Yes, I agree that the effect of executing these byte sequences is the
same as "mov (%ebx),%eax", but that's beside the point.  For example,
plenty of x86 instructions execute as a nop, but that doesn't mean they
should all be disassembled as "nop".  The disassembler ought to reflect
the machine encoding as closely as possible, and in this case that means
printing the ignored scale factor.

I think this change should be reverted.

> --- binutils/opcodes/i386-dis.c.sib	2004-11-04 09:35:19.000000000 -0800
> +++ binutils/opcodes/i386-dis.c	2005-01-12 10:50:01.790879515 -0800
> @@ -3191,8 +3191,10 @@ OP_E (int bytemode, int sizeflag)
>  	{
>  	  havesib = 1;
>  	  FETCH_DATA (the_info, codep + 1);
> -	  scale = (*codep >> 6) & 3;
>  	  index = (*codep >> 3) & 7;
> +	  if (index != 0x4)
> +	    /* When INDEX == 0x4, scale is ignored.  */
> +	    scale = (*codep >> 6) & 3;
>  	  base = *codep & 7;
>  	  USED_REX (REX_EXTY);
>  	  USED_REX (REX_EXTZ);

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2005-01-13  3:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20050111210753.0C8CB219E0@nexus.cs.usfca.edu>
2005-01-12 19:10 ` H. J. Lu
2005-01-13  3:44   ` Alan Modra [this message]
2005-01-13 17:09     ` H. J. Lu
2005-01-13 17:27       ` H. J. Lu
2005-01-14  0:06       ` Alan Modra
2005-01-14  0:27         ` H. J. Lu
2005-01-14  0:59           ` Alan Modra
2005-01-14 21:49             ` H. J. Lu
2005-01-14  7:04         ` Bernd Jendrissek
2005-01-13 17:42 Allan B. Cruse
2005-01-14  6:11 Allan B. Cruse
2005-01-14  7:32 ` Bernd Jendrissek
2005-01-14 17:19   ` E. Weddington

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=20050113034440.GG30985@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    --cc=cruse@cs.usfca.edu \
    --cc=hjl@lucon.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).