More immediate operand fixes for x86 disassembler.
authorUlrich Drepper <drepper@redhat.com>
Fri, 11 Jan 2008 07:18:44 +0000 (07:18 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 11 Jan 2008 07:18:44 +0000 (07:18 +0000)
libcpu/i386_data.h
tests/testfile45.S.bz2
tests/testfile45.expect.bz2

index c1f2d5e..5f66c61 100644 (file)
@@ -507,7 +507,11 @@ FCT_ax (struct output_data *d)
 
   bufp[(*bufcntp)++] = '%';
   if (! is_16bit)
-    bufp[(*bufcntp)++] = 'e';
+    bufp[(*bufcntp)++] = (
+#ifdef X86_64
+                         (*d->prefixes & has_rex_w) ? 'r' :
+#endif
+                         'e');
   bufp[(*bufcntp)++] = 'a';
   bufp[(*bufcntp)++] = 'x';
 
@@ -694,8 +698,14 @@ FCT_imm (struct output_data *d)
     {
       if (*d->param_start + 4 > d->end)
        return -1;
-      uint32_t word = read_4ubyte_unaligned_inc (*d->param_start);
-      needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, word);
+      int32_t word = read_4sbyte_unaligned_inc (*d->param_start);
+#ifdef X86_64
+      if (*d->prefixes & has_rex_w)
+       needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64,
+                          (int64_t) word);
+      else
+#endif
+       needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, word);
     }
   if ((size_t) needed > avail)
     return (size_t) needed - avail;
index 2fc2128..c39be44 100644 (file)
Binary files a/tests/testfile45.S.bz2 and b/tests/testfile45.S.bz2 differ
index cb054b6..539a03a 100644 (file)
Binary files a/tests/testfile45.expect.bz2 and b/tests/testfile45.expect.bz2 differ