static void OP_ST (instr_info *, int, int);
static void OP_STi (instr_info *, int, int);
static int putop (instr_info *, const char *, int);
+static void oappend_with_style (instr_info *, const char *,
+ enum disassembler_style);
static void oappend (instr_info *, const char *);
static void append_seg (instr_info *);
static void OP_indirE (instr_info *, int, int);
static void MOVSXD_Fixup (instr_info *, int, int);
static void DistinctDest_Fixup (instr_info *, int, int);
+/* This character is used to encode style information within the output
+ buffers. See oappend_insert_style for more details. */
+#define STYLE_MARKER_CHAR '\002'
+
struct dis_private {
/* Points to first byte not fetched. */
bfd_byte *max_fetched;
char scale_char;
enum x86_64_isa isa64;
-
};
/* Mark parts used in the REX prefix. When we are testing for
ins->has_sib = false;
}
-/* Like oappend (below), but S is a string starting with '%'.
- In Intel syntax, the '%' is elided. */
+/* Like oappend (below), but S is a string starting with '%' or '$'. In
+ Intel syntax, the '%' or '$' is elided. STYLE is used when displaying
+ this part of the output in the disassembler.
+
+ This function should not be used directly from the general disassembler
+ code, instead the helpers oappend_register and oappend_immediate should
+ be called as appropriate. */
+
+static void
+oappend_maybe_intel_with_style (instr_info *ins, const char *s,
+ enum disassembler_style style)
+{
+ oappend_with_style (ins, s + ins->intel_syntax, style);
+}
+
+/* Like oappend_maybe_intel_with_style above, but called when S is the
+ name of a register. */
+
static void
-oappend_maybe_intel (instr_info *ins, const char *s)
+oappend_register (instr_info *ins, const char *s)
+{
+ oappend_maybe_intel_with_style (ins, s, dis_style_register);
+}
+
+/* Like oappend_maybe_intel_with_style above, but called when S represents
+ an immediate. */
+
+static void
+oappend_immediate (instr_info *ins, const char *s)
+{
+ oappend_maybe_intel_with_style (ins, s, dis_style_immediate);
+}
+
+/* Wrap around a call to INS->info->fprintf_styled_func, printing FMT.
+ STYLE is the default style to use in the fprintf_styled_func calls,
+ however, FMT might include embedded style markers (see oappend_style),
+ these embedded markers are not printed, but instead change the style
+ used in the next fprintf_styled_func call.
+
+ Return non-zero to indicate the print call was a success. */
+
+static int ATTRIBUTE_PRINTF_3
+i386_dis_printf (instr_info *ins, enum disassembler_style style,
+ const char *fmt, ...)
{
- oappend (ins, s + ins->intel_syntax);
+ va_list ap;
+ enum disassembler_style curr_style = style;
+ char *start, *curr;
+ char staging_area[100];
+ int res;
+
+ va_start (ap, fmt);
+ res = vsnprintf (staging_area, sizeof (staging_area), fmt, ap);
+ va_end (ap);
+
+ if (res < 0)
+ return res;
+
+ if ((size_t) res >= sizeof (staging_area))
+ abort ();
+
+ start = curr = staging_area;
+
+ do
+ {
+ if (*curr == '\0'
+ || (*curr == STYLE_MARKER_CHAR
+ && ISXDIGIT (*(curr + 1))
+ && *(curr + 2) == STYLE_MARKER_CHAR))
+ {
+ /* Output content between our START position and CURR. */
+ int len = curr - start;
+ int n = (*ins->info->fprintf_styled_func) (ins->info->stream,
+ curr_style,
+ "%.*s", len, start);
+ if (n < 0)
+ {
+ res = n;
+ break;
+ }
+
+ if (*curr == '\0')
+ break;
+
+ /* Skip over the initial STYLE_MARKER_CHAR. */
+ ++curr;
+
+ /* Update the CURR_STYLE. As there are less than 16 styles, it
+ is possible, that if the input is corrupted in some way, that
+ we might set CURR_STYLE to an invalid value. Don't worry
+ though, we check for this situation. */
+ if (*curr >= '0' && *curr <= '9')
+ curr_style = (enum disassembler_style) (*curr - '0');
+ else if (*curr >= 'a' && *curr <= 'f')
+ curr_style = (enum disassembler_style) (*curr - 'a' + 10);
+ else
+ curr_style = dis_style_text;
+
+ /* Check for an invalid style having been selected. This should
+ never happen, but it doesn't hurt to be a little paranoid. */
+ if (curr_style > dis_style_comment_start)
+ curr_style = dis_style_text;
+
+ /* Skip the hex character, and the closing STYLE_MARKER_CHAR. */
+ curr += 2;
+
+ /* Reset the START to after the style marker. */
+ start = curr;
+ }
+ else
+ ++curr;
+ }
+ while (true);
+
+ return res;
}
static int
if (ins->address_mode == mode_64bit && sizeof (bfd_vma) < 8)
{
- (*ins->info->fprintf_styled_func) (ins->info->stream, dis_style_text,
- _("64-bit address is disabled"));
+ i386_dis_printf (ins, dis_style_text, _("64-bit address is disabled"));
return -1;
}
{
name = prefix_name (ins, priv.the_buffer[0], priv.orig_sizeflag);
if (name != NULL)
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "%s", name);
+ i386_dis_printf (ins, dis_style_mnemonic, "%s", name);
else
{
/* Just print the first byte as a .byte instruction. */
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_assembler_directive, ".byte ");
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_immediate, "0x%x",
- (unsigned int) priv.the_buffer[0]);
+ i386_dis_printf (ins, dis_style_assembler_directive,
+ ".byte ");
+ i386_dis_printf (ins, dis_style_immediate, "0x%x",
+ (unsigned int) priv.the_buffer[0]);
}
return 1;
for (i = 0;
i < (int) ARRAY_SIZE (ins->all_prefixes) && ins->all_prefixes[i];
i++)
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "%s%s",
- (i == 0 ? "" : " "), prefix_name (ins, ins->all_prefixes[i],
- sizeflag));
+ i386_dis_printf (ins, dis_style_mnemonic, "%s%s",
+ (i == 0 ? "" : " "),
+ prefix_name (ins, ins->all_prefixes[i], sizeflag));
return i;
}
/* Handle ins->prefixes before fwait. */
for (i = 0; i < ins->fwait_prefix && ins->all_prefixes[i];
i++)
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "%s ",
- prefix_name (ins, ins->all_prefixes[i], sizeflag));
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "fwait");
+ i386_dis_printf (ins, dis_style_mnemonic, "%s ",
+ prefix_name (ins, ins->all_prefixes[i], sizeflag));
+ i386_dis_printf (ins, dis_style_mnemonic, "fwait");
return i + 1;
}
/* Don't print {%k0}. */
if (ins->vex.mask_register_specifier)
{
+ const char *reg_name
+ = att_names_mask[ins->vex.mask_register_specifier];
oappend (ins, "{");
- oappend_maybe_intel (ins,
- att_names_mask
- [ins->vex.mask_register_specifier]);
+ oappend_register (ins, reg_name);
oappend (ins, "}");
}
if (ins->vex.zeroing)
are all 0s in inverted form. */
if (ins->need_vex && ins->vex.register_specifier != 0)
{
- (*ins->info->fprintf_styled_func) (ins->info->stream, dis_style_text,
- "(bad)");
+ i386_dis_printf (ins, dis_style_text, "(bad)");
return ins->end_codep - priv.the_buffer;
}
/* If EVEX.z is set, there must be an actual mask register in use. */
if (ins->vex.zeroing && ins->vex.mask_register_specifier == 0)
{
- (*ins->info->fprintf_styled_func) (ins->info->stream, dis_style_text,
- "(bad)");
+ i386_dis_printf (ins, dis_style_text, "(bad)");
return ins->end_codep - priv.the_buffer;
}
the encoding invalid. Most other PREFIX_OPCODE rules still apply. */
if (ins->need_vex ? !ins->vex.prefix : !(ins->prefixes & PREFIX_DATA))
{
- (*ins->info->fprintf_styled_func) (ins->info->stream,
- dis_style_text, "(bad)");
+ i386_dis_printf (ins, dis_style_text, "(bad)");
return ins->end_codep - priv.the_buffer;
}
ins->used_prefixes |= PREFIX_DATA;
|| (ins->vex.evex && dp->prefix_requirement != PREFIX_DATA
&& !ins->vex.w != !(ins->used_prefixes & PREFIX_DATA)))
{
- (*ins->info->fprintf_styled_func) (ins->info->stream,
- dis_style_text, "(bad)");
+ i386_dis_printf (ins, dis_style_text, "(bad)");
return ins->end_codep - priv.the_buffer;
}
break;
if (name == NULL)
abort ();
prefix_length += strlen (name) + 1;
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "%s ", name);
+ i386_dis_printf (ins, dis_style_mnemonic, "%s ", name);
}
/* Check maximum code length. */
if ((ins->codep - ins->start_codep) > MAX_CODE_LENGTH)
{
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_text, "(bad)");
+ i386_dis_printf (ins, dis_style_text, "(bad)");
return MAX_CODE_LENGTH;
}
i = 0;
/* Print the instruction mnemonic along with any trailing whitespace. */
- (*ins->info->fprintf_styled_func)
- (ins->info->stream, dis_style_mnemonic, "%s%*s", ins->obuf, i, "");
+ i386_dis_printf (ins, dis_style_mnemonic, "%s%*s", ins->obuf, i, "");
/* The enter and bound instructions are printed with operands in the same
order as the intel book; everything else is printed in reverse order. */
break;
}
if (needcomma)
- (*ins->info->fprintf_styled_func) (ins->info->stream,
- dis_style_text, ",");
+ i386_dis_printf (ins, dis_style_text, ",");
if (ins->op_index[i] != -1 && !ins->op_riprel[i])
{
bfd_vma target = (bfd_vma) ins->op_address[ins->op_index[i]];
(*ins->info->print_address_func) (target, ins->info);
}
else
- (*ins->info->fprintf_styled_func) (ins->info->stream,
- dis_style_text, "%s",
- op_txt[i]);
+ i386_dis_printf (ins, dis_style_text, "%s", op_txt[i]);
needcomma = 1;
}
for (i = 0; i < MAX_OPERANDS; i++)
if (ins->op_index[i] != -1 && ins->op_riprel[i])
{
- (*ins->info->fprintf_styled_func) (ins->info->stream,
- dis_style_comment_start,
- " # ");
+ i386_dis_printf (ins, dis_style_comment_start, " # ");
(*ins->info->print_address_func) ((bfd_vma)
(ins->start_pc + (ins->codep - ins->start_codep)
+ ins->op_address[ins->op_index[i]]), ins->info);
OP_ST (instr_info *ins, int bytemode ATTRIBUTE_UNUSED,
int sizeflag ATTRIBUTE_UNUSED)
{
- oappend_maybe_intel (ins, "%st");
+ oappend_register (ins, "%st");
}
static void
int sizeflag ATTRIBUTE_UNUSED)
{
sprintf (ins->scratchbuf, "%%st(%d)", ins->modrm.rm);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_register (ins, ins->scratchbuf);
}
/* Capital letters in template are macros. */
return 0;
}
+/* Add a style marker to *INS->obufp that encodes STYLE. This assumes that
+ the buffer pointed to by INS->obufp has space. A style marker is made
+ from the STYLE_MARKER_CHAR followed by STYLE converted to a single hex
+ digit, followed by another STYLE_MARKER_CHAR. This function assumes
+ that the number of styles is not greater than 16. */
+
static void
-oappend (instr_info *ins, const char *s)
+oappend_insert_style (instr_info *ins, enum disassembler_style style)
{
+ unsigned num = (unsigned) style;
+
+ /* We currently assume that STYLE can be encoded as a single hex
+ character. If more styles are added then this might start to fail,
+ and we'll need to expand this code. */
+ if (num > 0xf)
+ abort ();
+
+ *ins->obufp++ = STYLE_MARKER_CHAR;
+ *ins->obufp++ = (num < 10 ? ('0' + num)
+ : ((num < 16) ? ('a' + (num - 10)) : '0'));
+ *ins->obufp++ = STYLE_MARKER_CHAR;
+
+ /* This final null character is not strictly necessary, after inserting a
+ style marker we should always be inserting some additional content.
+ However, having the buffer null terminated doesn't cost much, and make
+ it easier to debug what's going on. Also, if we do ever forget to add
+ any additional content after this style marker, then the buffer will
+ still be well formed. */
+ *ins->obufp = '\0';
+}
+
+static void
+oappend_with_style (instr_info *ins, const char *s,
+ enum disassembler_style style)
+{
+ oappend_insert_style (ins, style);
ins->obufp = stpcpy (ins->obufp, s);
}
+/* Like oappend_with_style but always with text style. */
+
+static void
+oappend (instr_info *ins, const char *s)
+{
+ oappend_with_style (ins, s, dis_style_text);
+}
+
+/* Add a single character C to the buffer pointer to by INS->obufp, marking
+ the style for the character as STYLE. */
+
+static void
+oappend_char_with_style (instr_info *ins, const char c,
+ enum disassembler_style style)
+{
+ oappend_insert_style (ins, style);
+ *ins->obufp++ = c;
+ *ins->obufp = '\0';
+}
+
+/* Like oappend_char_with_style, but always uses dis_style_text. */
+
+static void
+oappend_char (instr_info *ins, const char c)
+{
+ oappend_char_with_style (ins, c, dis_style_text);
+}
+
static void
append_seg (instr_info *ins)
{
switch (ins->active_seg_prefix)
{
case PREFIX_CS:
- oappend_maybe_intel (ins, "%cs:");
+ oappend_register (ins, "%cs");
break;
case PREFIX_DS:
- oappend_maybe_intel (ins, "%ds:");
+ oappend_register (ins, "%ds");
break;
case PREFIX_SS:
- oappend_maybe_intel (ins, "%ss:");
+ oappend_register (ins, "%ss");
break;
case PREFIX_ES:
- oappend_maybe_intel (ins, "%es:");
+ oappend_register (ins, "%es");
break;
case PREFIX_FS:
- oappend_maybe_intel (ins, "%fs:");
+ oappend_register (ins, "%fs");
break;
case PREFIX_GS:
- oappend_maybe_intel (ins, "%gs:");
+ oappend_register (ins, "%gs");
break;
default:
break;
}
+ oappend_char (ins, ':');
}
static void
oappend (ins, INTERNAL_DISASSEMBLER_ERROR);
return;
}
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
static void
print_displacement (ins, ins->scratchbuf, disp);
else
print_operand_value (ins, ins->scratchbuf, 1, disp);
- oappend (ins, ins->scratchbuf);
+ oappend_with_style (ins, ins->scratchbuf,
+ dis_style_address_offset);
if (riprel)
{
set_op (ins, disp, true);
- oappend (ins, !addr32flag ? "(%rip)" : "(%eip)");
+ oappend_char (ins, '(');
+ oappend_with_style (ins, !addr32flag ? "%rip" : "%eip",
+ dis_style_register);
+ oappend_char (ins, ')');
}
}
if (havedisp || (ins->intel_syntax && riprel))
{
- *ins->obufp++ = ins->open_char;
+ oappend_char (ins, ins->open_char);
if (ins->intel_syntax && riprel)
{
set_op (ins, disp, true);
- oappend (ins, !addr32flag ? "rip" : "eip");
+ oappend_with_style (ins, !addr32flag ? "rip" : "eip",
+ dis_style_register);
}
- *ins->obufp = '\0';
if (havebase)
- oappend_maybe_intel (ins,
- (ins->address_mode == mode_64bit && !addr32flag
- ? att_names64 : att_names32)[rbase]);
+ oappend_register
+ (ins,
+ (ins->address_mode == mode_64bit && !addr32flag
+ ? att_names64 : att_names32)[rbase]);
if (ins->has_sib)
{
/* ESP/RSP won't allow index. If base isn't ESP/RSP,
|| (havebase && base != ESP_REG_NUM))
{
if (!ins->intel_syntax || havebase)
- {
- *ins->obufp++ = ins->separator_char;
- *ins->obufp = '\0';
- }
+ oappend_char (ins, ins->separator_char);
if (indexes)
{
if (ins->address_mode == mode_64bit || vindex < 16)
- oappend_maybe_intel (ins, indexes[vindex]);
+ oappend_register (ins, indexes[vindex]);
else
oappend (ins, "(bad)");
}
else
- oappend_maybe_intel (ins,
- ins->address_mode == mode_64bit
- && !addr32flag ? att_index64
- : att_index32);
+ oappend_register (ins,
+ ins->address_mode == mode_64bit
+ && !addr32flag
+ ? att_index64
+ : att_index32);
- *ins->obufp++ = ins->scale_char;
- *ins->obufp = '\0';
+ oappend_char (ins, ins->scale_char);
sprintf (ins->scratchbuf, "%d", 1 << scale);
- oappend (ins, ins->scratchbuf);
+ oappend_with_style (ins, ins->scratchbuf,
+ dis_style_immediate);
}
}
if (ins->intel_syntax
&& (disp || ins->modrm.mod != 0 || base == 5))
{
if (!havedisp || (bfd_signed_vma) disp >= 0)
- {
- *ins->obufp++ = '+';
- *ins->obufp = '\0';
- }
+ oappend_char (ins, '+');
else if (ins->modrm.mod != 1 && disp != -disp)
{
- *ins->obufp++ = '-';
- *ins->obufp = '\0';
+ oappend_char (ins, '-');
disp = -disp;
}
oappend (ins, ins->scratchbuf);
}
- *ins->obufp++ = ins->close_char;
- *ins->obufp = '\0';
+ oappend_char (ins, ins->close_char);
if (check_gather)
{
{
if (!ins->active_seg_prefix)
{
- oappend_maybe_intel (ins, att_names_seg[ds_reg - es_reg]);
+ oappend_register (ins, att_names_seg[ds_reg - es_reg]);
oappend (ins, ":");
}
print_operand_value (ins, ins->scratchbuf, 1, disp);
if (ins->modrm.mod != 0 || ins->modrm.rm != 6)
{
- *ins->obufp++ = ins->open_char;
- *ins->obufp = '\0';
- oappend (ins,
- (ins->intel_syntax ? intel_index16
- : att_index16)[ins->modrm.rm]);
+ oappend_char (ins, ins->open_char);
+ oappend (ins, (ins->intel_syntax ? intel_index16
+ : att_index16)[ins->modrm.rm]);
if (ins->intel_syntax
&& (disp || ins->modrm.mod != 0 || ins->modrm.rm == 6))
{
if ((bfd_signed_vma) disp >= 0)
- {
- *ins->obufp++ = '+';
- *ins->obufp = '\0';
- }
+ oappend_char (ins, '+');
else if (ins->modrm.mod != 1)
{
- *ins->obufp++ = '-';
- *ins->obufp = '\0';
+ oappend_char (ins, '-');
disp = -disp;
}
oappend (ins, ins->scratchbuf);
}
- *ins->obufp++ = ins->close_char;
- *ins->obufp = '\0';
+ oappend_char (ins, ins->close_char);
}
else if (ins->intel_syntax)
{
if (!ins->active_seg_prefix)
{
- oappend_maybe_intel (ins, att_names_seg[ds_reg - es_reg]);
+ oappend_register (ins, att_names_seg[ds_reg - es_reg]);
oappend (ins, ":");
}
print_operand_value (ins, ins->scratchbuf, 1, disp & 0xffff);
{
case es_reg: case ss_reg: case cs_reg:
case ds_reg: case fs_reg: case gs_reg:
- oappend_maybe_intel (ins, att_names_seg[code - es_reg]);
+ oappend_register (ins, att_names_seg[code - es_reg]);
return;
}
oappend (ins, INTERNAL_DISASSEMBLER_ERROR);
return;
}
- oappend_maybe_intel (ins, s);
+ oappend_register (ins, s);
}
static void
oappend (ins, INTERNAL_DISASSEMBLER_ERROR);
return;
}
- oappend_maybe_intel (ins, s);
+ oappend_register (ins, s);
}
static void
op &= mask;
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, op);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, get64 (ins));
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, op);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
}
static void
OP_SEG (instr_info *ins, int bytemode, int sizeflag)
{
if (bytemode == w_mode)
- oappend_maybe_intel (ins, att_names_seg[ins->modrm.reg]);
+ oappend_register (ins, att_names_seg[ins->modrm.reg]);
else
OP_E (ins, ins->modrm.mod == 3 ? bytemode : w_mode, sizeflag);
}
{
if (!ins->active_seg_prefix)
{
- oappend_maybe_intel (ins, att_names_seg[ds_reg - es_reg]);
+ oappend_register (ins, att_names_seg[ds_reg - es_reg]);
oappend (ins, ":");
}
}
print_operand_value (ins, ins->scratchbuf, 1, off);
- oappend (ins, ins->scratchbuf);
+ oappend_with_style (ins, ins->scratchbuf, dis_style_address_offset);
}
static void
{
if (!ins->active_seg_prefix)
{
- oappend_maybe_intel (ins, att_names_seg[ds_reg - es_reg]);
+ oappend_register (ins, att_names_seg[ds_reg - es_reg]);
oappend (ins, ":");
}
}
print_operand_value (ins, ins->scratchbuf, 1, off);
- oappend (ins, ins->scratchbuf);
+ oappend_with_style (ins, ins->scratchbuf, dis_style_address_offset);
}
static void
s = att_names32[code - eAX_reg];
else
s = att_names16[code - eAX_reg];
- oappend_maybe_intel (ins, s);
- *ins->obufp++ = ins->close_char;
- *ins->obufp = 0;
+ oappend_register (ins, s);
+ oappend_char (ins, ins->close_char);
}
static void
intel_operand_size (ins, b_mode, sizeflag);
}
}
- oappend_maybe_intel (ins, "%es:");
+ oappend_register (ins, "%es");
+ oappend_char (ins, ':');
ptr_reg (ins, code, sizeflag);
}
else
add = 0;
sprintf (ins->scratchbuf, "%%cr%d", ins->modrm.reg + add);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_register (ins, ins->scratchbuf);
}
static void
int sizeflag ATTRIBUTE_UNUSED)
{
sprintf (ins->scratchbuf, "%%tr%d", ins->modrm.reg);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_register (ins, ins->scratchbuf);
}
static void
}
else
names = att_names_mm;
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
static void
}
else
names = att_names_xmm;
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
static void
}
else
names = att_names_mm;
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
/* cvt* are the only instructions in sse2 which have
MODRM_CHECK;
ins->codep++;
ins->used_prefixes |= (ins->prefixes & PREFIX_DATA);
- oappend_maybe_intel (ins, att_names_mm[ins->modrm.rm]);
+ oappend_register (ins, att_names_mm[ins->modrm.rm]);
}
static void
int sizeflag ATTRIBUTE_UNUSED)
{
ins->used_prefixes |= (ins->prefixes & PREFIX_DATA);
- oappend_maybe_intel (ins, att_names_mm[ins->modrm.reg]);
+ oappend_register (ins, att_names_mm[ins->modrm.reg]);
}
static void
ins->obufp = ins->mnemonicendp;
mnemonic = Suffix3DNow[*ins->codep++ & 0xff];
if (mnemonic)
- oappend (ins, mnemonic);
+ ins->obufp = stpcpy (ins->obufp, mnemonic);
else
{
/* Since a variable sized ins->modrm/ins->sib chunk is between the start
/* We have a reserved extension byte. Output it directly. */
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, cmp_type);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
}
{
/* Throw away prefixes and 1st. opcode byte. */
ins->codep = ins->insn_codep + 1;
- oappend (ins, "(bad)");
+ ins->obufp = stpcpy (ins->obufp, "(bad)");
}
static void
abort ();
}
}
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
static void
switch (bytemode)
{
case scalar_mode:
- oappend_maybe_intel (ins, att_names_xmm[reg]);
+ oappend_register (ins, att_names_xmm[reg]);
return;
case vex_vsib_d_w_dq_mode:
if (ins->vex.length == 128
|| (bytemode != vex_vsib_d_w_dq_mode
&& !ins->vex.w))
- oappend_maybe_intel (ins, att_names_xmm[reg]);
+ oappend_register (ins, att_names_xmm[reg]);
else
- oappend_maybe_intel (ins, att_names_ymm[reg]);
+ oappend_register (ins, att_names_ymm[reg]);
/* All 3 XMM/YMM registers must be distinct. */
modrm_reg = ins->modrm.reg;
/* This must be the 3rd operand. */
if (ins->obufp != ins->op_out[2])
abort ();
- oappend_maybe_intel (ins, att_names_tmm[reg]);
+ oappend_register (ins, att_names_tmm[reg]);
if (reg == ins->modrm.reg || reg == ins->modrm.rm)
strcpy (ins->obufp, "/(bad)");
}
abort ();
break;
}
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
}
static void
if (bytemode == x_mode && ins->vex.length == 256)
names = att_names_ymm;
- oappend_maybe_intel (ins, names[reg]);
+ oappend_register (ins, names[reg]);
if (ins->vex.w)
{
{
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, ins->codep[-1] & 0xf);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
}
static void
/* We have a reserved extension byte. Output it directly. */
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, cmp_type);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
}
/* We have a reserved extension byte. Output it directly. */
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, cmp_type);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
}
/* We have a reserved extension byte. Output it directly. */
ins->scratchbuf[0] = '$';
print_operand_value (ins, ins->scratchbuf + 1, 1, pclmul_type);
- oappend_maybe_intel (ins, ins->scratchbuf);
+ oappend_immediate (ins, ins->scratchbuf);
ins->scratchbuf[0] = '\0';
}
}