Optimize disassembler a bit.

This commit is contained in:
Ulrich Drepper
2008-01-11 06:55:16 +00:00
parent 96a739922f
commit 6bc105fc2c
2 changed files with 16 additions and 18 deletions
+4
View File
@@ -1,5 +1,9 @@
2008-01-10 Ulrich Drepper <drepper@redhat.com>
* i386_data.h (FCT_crdb): New function.
(FCT_ccc): Use FCT_crdb.
(FCT_ddd): Likewise.
* defs/i386: Fix a few instructions with immediate arguments.
* i386_disasm.c: Rewrite interface to callback functions for operands
+12 -18
View File
@@ -537,7 +537,8 @@ FCT_ax$w (struct output_data *d)
static int
FCT_ccc (struct output_data *d)
__attribute__ ((noinline))
FCT_crdb (struct output_data *d, const char *regstr)
{
if (*d->prefixes & has_data16)
return -1;
@@ -548,8 +549,8 @@ FCT_ccc (struct output_data *d)
assert (d->opoff1 / 8 == 2);
assert (d->opoff1 % 8 == 2);
size_t avail = d->bufsize - *bufcntp;
int needed = snprintf (&d->bufp[*bufcntp], avail, "%%cr%" PRIx32,
(uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7);
int needed = snprintf (&d->bufp[*bufcntp], avail, "%%%s%" PRIx32,
regstr, (uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7);
if ((size_t) needed > avail)
return needed - avail;
*bufcntp += needed;
@@ -557,24 +558,17 @@ FCT_ccc (struct output_data *d)
}
static int
FCT_ccc (struct output_data *d)
{
return FCT_crdb (d, "cr");
}
static int
FCT_ddd (struct output_data *d)
{
if (*d->prefixes & has_data16)
return -1;
size_t *bufcntp = d->bufcntp;
// XXX If this assert is true, use absolute offset below
assert (d->opoff1 / 8 == 2);
assert (d->opoff1 % 8 == 2);
size_t avail = d->bufsize - *bufcntp;
int needed = snprintf (&d->bufp[*bufcntp], avail, "%%db%" PRIx32,
(uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7);
if ((size_t) needed > avail)
return needed - avail;
*bufcntp += needed;
return 0;
return FCT_crdb (d, "db");
}