aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2007-04-27 04:22:02 +0000
committerH.J. Lu <hjl.tools@gmail.com>2007-04-27 04:22:02 +0000
commit5d6696482af3f34be30e71905739afeb3b9d42f4 (patch)
treeabdc6cba251d9146227887cc48a4f4498c96f3e1 /opcodes
parent2ce18a16268a1934ac7f578fc9bda064312f72f9 (diff)
downloadgdb-5d6696482af3f34be30e71905739afeb3b9d42f4.zip
gdb-5d6696482af3f34be30e71905739afeb3b9d42f4.tar.gz
gdb-5d6696482af3f34be30e71905739afeb3b9d42f4.tar.bz2
gas/testsuite/
2007-04-26 H.J. Lu <hongjiu.lu@intel.com> PR binutils/4430 * gas/i386/amd.d: Updated. * gas/i386/immed32.d: Likewise. * gas/i386/intel.d: Likewise. * gas/i386/intel16.d: Likewise. * gas/i386/intelok.d: Likewise. * gas/i386/jump16.d: Likewise. * gas/i386/naked.d: Likewise. * gas/i386/opcode-suffix.d: Likewise. * gas/i386/opcode.d: Likewise. * gas/i386/prescott.d: Likewise. * gas/i386/ssemmx2.d: Likewise. * gas/i386/tlsd.d: Likewise. * gas/i386/tlspic.d: Likewise. * gas/i386/x86-64-addr32.d: Likewise. * gas/i386/x86-64-prescott.d: Likewise. * gas/i386/x86-64-rip.d: Likewise. * gas/i386/x86_64.d: Likewise. ld/testsuite/ 2007-04-26 H.J. Lu <hongjiu.lu@intel.com> PR binutils/4430 * ld-i386/tlsbin.dd: Updated. * ld-i386/tlsbindesc.dd: Likewise * ld-i386/tlsdesc.dd: Likewise * ld-i386/tlsgdesc.dd: Likewise * ld-i386/tlsnopic.dd: Likewise * ld-i386/tlspic.dd: Likewise * ld-x86-64/tlsbin.dd: Likewise * ld-x86-64/tlsbindesc.dd: Likewise * ld-x86-64/tlsdesc.dd: Likewise * ld-x86-64/tlsgdesc.dd: Likewise * ld-x86-64/tlspic.dd: Likewise opcodes/ 2007-04-26 H.J. Lu <hongjiu.lu@intel.com> PR binutils/4430 * i386-dis.c (print_displacement): New. (OP_E): Call print_displacement instead of print_operand_value to output displacement when either base or index exist. Print the explicit zero displacement in 16bit mode.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog8
-rw-r--r--opcodes/i386-dis.c71
2 files changed, 69 insertions, 10 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 3521979..5f84dc9 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,13 @@
2007-04-26 H.J. Lu <hongjiu.lu@intel.com>
+ PR binutils/4430
+ * i386-dis.c (print_displacement): New.
+ (OP_E): Call print_displacement instead of print_operand_value
+ to output displacement when either base or index exist. Print
+ the explicit zero displacement in 16bit mode.
+
+2007-04-26 H.J. Lu <hongjiu.lu@intel.com>
+
PR binutils/4429
* i386-dis.c (print_insn): Also swap the order of op_riprel
when swapping op_index. Break when the RIP relative address
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 9fd62f2..511355e 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -50,6 +50,7 @@ static void oappend (const char *);
static void append_seg (void);
static void OP_indirE (int, int);
static void print_operand_value (char *, int, bfd_vma);
+static void print_displacement (char *, bfd_vma);
static void OP_E (int, int);
static void OP_G (int, int);
static bfd_vma get64 (void);
@@ -4629,6 +4630,50 @@ print_operand_value (char *buf, int hex, bfd_vma disp)
}
}
+/* Put DISP in BUF as signed hex number. */
+
+static void
+print_displacement (char *buf, bfd_vma disp)
+{
+ bfd_signed_vma val = disp;
+ char tmp[30];
+ int i, j = 0;
+
+ if (val < 0)
+ {
+ buf[j++] = '-';
+ val = -disp;
+
+ /* Check for possible overflow. */
+ if (val < 0)
+ {
+ switch (address_mode)
+ {
+ case mode_64bit:
+ strcpy (buf + j, "0x8000000000000000");
+ break;
+ case mode_32bit:
+ strcpy (buf + j, "0x80000000");
+ break;
+ case mode_16bit:
+ strcpy (buf + j, "0x8000");
+ break;
+ }
+ return;
+ }
+ }
+
+ buf[j++] = '0';
+ buf[j++] = 'x';
+
+ sprintf_vma (tmp, val);
+ for (i = 0; tmp[i] == '0'; i++)
+ continue;
+ if (tmp[i] == '\0')
+ i--;
+ strcpy (buf + j, tmp + i);
+}
+
static void
intel_operand_size (int bytemode, int sizeflag)
{
@@ -4779,8 +4824,10 @@ OP_E (int bytemode, int sizeflag)
intel_operand_size (bytemode, sizeflag);
append_seg ();
- if ((sizeflag & AFLAG) || address_mode == mode_64bit) /* 32 bit address mode */
+ if ((sizeflag & AFLAG) || address_mode == mode_64bit)
{
+ /* 32/64 bit address mode */
+ int havedisp;
int havesib;
int havebase;
int base;
@@ -4829,10 +4876,15 @@ OP_E (int bytemode, int sizeflag)
break;
}
+ havedisp = havebase || (havesib && (index != 4 || scale != 0));
+
if (!intel_syntax)
if (modrm.mod != 0 || (base & 7) == 5)
{
- print_operand_value (scratchbuf, !riprel, disp);
+ if (havedisp || riprel)
+ print_displacement (scratchbuf, disp);
+ else
+ print_operand_value (scratchbuf, 1, disp);
oappend (scratchbuf);
if (riprel)
{
@@ -4841,9 +4893,7 @@ OP_E (int bytemode, int sizeflag)
}
}
- if (havebase
- || (intel_syntax && riprel)
- || (havesib && (index != 4 || scale != 0)))
+ if (havedisp || (intel_syntax && riprel))
{
*obufp++ = open_char;
if (intel_syntax && riprel)
@@ -4890,7 +4940,7 @@ OP_E (int bytemode, int sizeflag)
disp = - (bfd_signed_vma) disp;
}
- print_operand_value (scratchbuf, modrm.mod != 1, disp);
+ print_displacement (scratchbuf, disp);
oappend (scratchbuf);
}
@@ -4942,7 +4992,7 @@ OP_E (int bytemode, int sizeflag)
if (!intel_syntax)
if (modrm.mod != 0 || modrm.rm == 6)
{
- print_operand_value (scratchbuf, 0, disp);
+ print_displacement (scratchbuf, disp);
oappend (scratchbuf);
}
@@ -4951,9 +5001,10 @@ OP_E (int bytemode, int sizeflag)
*obufp++ = open_char;
*obufp = '\0';
oappend (index16[modrm.rm]);
- if (intel_syntax && disp)
+ if (intel_syntax
+ && (disp || modrm.mod != 0 || modrm.rm == 6))
{
- if ((bfd_signed_vma) disp > 0)
+ if ((bfd_signed_vma) disp >= 0)
{
*obufp++ = '+';
*obufp = '\0';
@@ -4965,7 +5016,7 @@ OP_E (int bytemode, int sizeflag)
disp = - (bfd_signed_vma) disp;
}
- print_operand_value (scratchbuf, modrm.mod != 1, disp);
+ print_displacement (scratchbuf, disp);
oappend (scratchbuf);
}