public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Add SIB
@ 2010-05-26 16:10 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2010-05-26 16:10 UTC (permalink / raw)
  To: binutils

Hi,

I checked in this patch to add SIB to make it easier to exam SIB bits.

H.J.
---
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 29dd295..fe7557e 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* i386-dis.c (sib): New.
+	(get_sib): Likewise.
+	(print_insn): Call get_sib.
+	OP_E_memory): Use sib.
+
 2010-05-26  Catherine Moore  <clm@codesoourcery.com>
 
 	* mips-dis.c (mips_arch): Remove INSN_MIPS16.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index fef9185..ecd8cca 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -2305,6 +2305,13 @@ modrm;
 static unsigned char need_modrm;
 static struct
   {
+    int scale;
+    int index;
+    int base;
+  }
+sib;
+static struct
+  {
     int register_specifier;
     int length;
     int prefix;
@@ -11243,6 +11250,22 @@ get_valid_dis386 (const struct dis386 *dp, disassemble_info *info)
     return get_valid_dis386 (dp, info);
 }
 
+static void
+get_sib (disassemble_info *info)
+{
+  /* If modrm.mod == 3, operand must be register.  */
+  if (need_modrm
+      && address_mode != mode_16bit
+      && modrm.mod != 3
+      && modrm.rm == 4)
+    {
+      FETCH_DATA (info, codep + 2);
+      sib.index = (codep [1] >> 3) & 7;
+      sib.scale = (codep [1] >> 6) & 3;
+      sib.base = codep [1] & 7;
+    }
+}
+
 static int
 print_insn (bfd_vma pc, disassemble_info *info)
 {
@@ -11528,6 +11551,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
 
   if (dp->name == NULL && dp->op[0].bytemode == FLOATCODE)
     {
+      get_sib (info);
       dofloat (sizeflag);
     }
   else
@@ -11535,6 +11559,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
       dp = get_valid_dis386 (dp, info);
       if (dp != NULL && putop (dp->name, sizeflag) == 0)
         {
+	  get_sib (info);
 	  for (i = 0; i < MAX_OPERANDS; ++i)
 	    {
 	      obufp = op_out[i];
@@ -12935,10 +12960,9 @@ OP_E_memory (int bytemode, int sizeflag)
       if (base == 4)
 	{
 	  havesib = 1;
-	  FETCH_DATA (the_info, codep + 1);
-	  vindex = (*codep >> 3) & 7;
-	  scale = (*codep >> 6) & 3;
-	  base = *codep & 7;
+	  vindex = sib.index;
+	  scale = sib.scale;
+	  base = sib.base;
 	  USED_REX (REX_X);
 	  if (rex & REX_X)
 	    vindex += 8;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-26 16:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-26 16:10 PATCH: Add SIB H.J. Lu

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).