opcodes: style m68k disassembler output

This commit is contained in:
Andreas Schwab
2023-02-14 18:07:19 +01:00
committed by Andreas Schwab
parent 19005d1989
commit c22ff44927

View File

@ -213,7 +213,8 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
/* This function is used to print to the bit-bucket. */ /* This function is used to print to the bit-bucket. */
static int static int
dummy_printer (FILE *file ATTRIBUTE_UNUSED, dummy_printer (void *file ATTRIBUTE_UNUSED,
enum disassembler_style style ATTRIBUTE_UNUSED,
const char *format ATTRIBUTE_UNUSED, const char *format ATTRIBUTE_UNUSED,
...) ...)
{ {
@ -510,18 +511,39 @@ print_base (int regno, bfd_vma disp, disassemble_info *info)
{ {
if (regno == -1) if (regno == -1)
{ {
(*info->fprintf_func) (info->stream, "%%pc@("); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->print_address_func) (disp, info); (*info->print_address_func) (disp, info);
} }
else else
{ {
if (regno == -2) if (regno == -3)
(*info->fprintf_func) (info->stream, "@("); (*info->fprintf_styled_func) (info->stream, dis_style_register,
else if (regno == -3) "%%zpc");
(*info->fprintf_func) (info->stream, "%%zpc@("); else if (regno != -2)
else (*info->fprintf_styled_func) (info->stream, dis_style_register,
(*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]); "%s", reg_names[regno]);
(*info->fprintf_func) (info->stream, "%" PRIx64, (uint64_t) disp); (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"%" PRIx64, (uint64_t) disp);
}
}
/* Print the index register of an indexed argument, as encoded in the
extension word. */
static void
print_index_register (int ext, disassemble_info *info)
{
(*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[(ext >> 12) & 0xf]);
(*info->fprintf_styled_func) (info->stream, dis_style_text,
":%c", ext & 0x800 ? 'l' : 'w');
if ((ext >> 9) & 3)
{
(*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"%d", 1 << ((ext >> 9) & 3));
} }
} }
@ -537,20 +559,12 @@ print_indexed (int basereg,
disassemble_info *info) disassemble_info *info)
{ {
int word; int word;
static char *const scales[] = { "", ":2", ":4", ":8" };
bfd_vma base_disp; bfd_vma base_disp;
bfd_vma outer_disp; bfd_vma outer_disp;
char buf[40]; bool print_index = true;
NEXTWORD (p, word, NULL); NEXTWORD (p, word, NULL);
/* Generate the text for the index register.
Where this will be output is not yet determined. */
sprintf (buf, "%s:%c%s",
reg_names[(word >> 12) & 0xf],
(word & 0x800) ? 'l' : 'w',
scales[(word >> 9) & 3]);
/* Handle the 68000 style of indexing. */ /* Handle the 68000 style of indexing. */
if ((word & 0x100) == 0) if ((word & 0x100) == 0)
@ -561,7 +575,9 @@ print_indexed (int basereg,
if (basereg == -1) if (basereg == -1)
base_disp += addr; base_disp += addr;
print_base (basereg, base_disp, info); print_base (basereg, base_disp, info);
(*info->fprintf_func) (info->stream, ",%s)", buf); (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
print_index_register (word, info);
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
return p; return p;
} }
@ -575,7 +591,7 @@ print_indexed (int basereg,
basereg = -2; basereg = -2;
} }
if (word & 0100) if (word & 0100)
buf[0] = '\0'; print_index = false;
base_disp = 0; base_disp = 0;
switch ((word >> 4) & 3) switch ((word >> 4) & 3)
{ {
@ -592,9 +608,12 @@ print_indexed (int basereg,
if ((word & 7) == 0) if ((word & 7) == 0)
{ {
print_base (basereg, base_disp, info); print_base (basereg, base_disp, info);
if (buf[0] != '\0') if (print_index)
(*info->fprintf_func) (info->stream, ",%s", buf); {
(*info->fprintf_func) (info->stream, ")"); (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
print_index_register (word, info);
}
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
return p; return p;
} }
@ -610,15 +629,22 @@ print_indexed (int basereg,
} }
print_base (basereg, base_disp, info); print_base (basereg, base_disp, info);
if ((word & 4) == 0 && buf[0] != '\0') if ((word & 4) == 0 && print_index)
{ {
(*info->fprintf_func) (info->stream, ",%s", buf); (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
buf[0] = '\0'; print_index_register (word, info);
print_index = false;
} }
(*info->fprintf_func) (info->stream, ")@(%" PRIx64, (uint64_t) outer_disp); (*info->fprintf_styled_func) (info->stream, dis_style_text,
if (buf[0] != '\0') ")@(");
(*info->fprintf_func) (info->stream, ",%s", buf); (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
(*info->fprintf_func) (info->stream, ")"); "%" PRIx64, (uint64_t) outer_disp);
if (print_index)
{
(*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
print_index_register (word, info);
}
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
return p; return p;
} }
@ -660,14 +686,17 @@ print_insn_arg (const char *d,
{ {
static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" }; static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
FETCH_ARG (2, val); FETCH_ARG (2, val);
(*info->fprintf_func) (info->stream, "%s", cacheFieldName[val]); (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
"%s", cacheFieldName[val]);
break; break;
} }
case 'a': /* Address register indirect only. Cf. case '+'. */ case 'a': /* Address register indirect only. Cf. case '+'. */
{ {
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s@", reg_names[val + 8]); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
reg_names[val + 8]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
break; break;
} }
@ -679,27 +708,27 @@ print_insn_arg (const char *d,
} }
case 'C': case 'C':
(*info->fprintf_func) (info->stream, "%%ccr"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
break; break;
case 'S': case 'S':
(*info->fprintf_func) (info->stream, "%%sr"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
break; break;
case 'U': case 'U':
(*info->fprintf_func) (info->stream, "%%usp"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
break; break;
case 'E': case 'E':
(*info->fprintf_func) (info->stream, "%%acc"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
break; break;
case 'G': case 'G':
(*info->fprintf_func) (info->stream, "%%macsr"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
break; break;
case 'H': case 'H':
(*info->fprintf_func) (info->stream, "%%mask"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
break; break;
case 'J': case 'J':
@ -749,7 +778,8 @@ print_insn_arg (const char *d,
for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;) for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
if (names_v4e[regno].value == val) if (names_v4e[regno].value == val)
{ {
(*info->fprintf_func) (info->stream, "%s", names_v4e[regno].name); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", names_v4e[regno].name);
break; break;
} }
if (regno >= 0) if (regno >= 0)
@ -758,11 +788,12 @@ print_insn_arg (const char *d,
for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--) for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
if (names[regno].value == val) if (names[regno].value == val)
{ {
(*info->fprintf_func) (info->stream, "%s", names[regno].name); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", names[regno].name);
break; break;
} }
if (regno < 0) if (regno < 0)
(*info->fprintf_func) (info->stream, "0x%x", val); (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
} }
break; break;
@ -771,7 +802,8 @@ print_insn_arg (const char *d,
/* 0 means 8, except for the bkpt instruction... */ /* 0 means 8, except for the bkpt instruction... */
if (val == 0 && d[1] != 's') if (val == 0 && d[1] != 's')
val = 8; val = 8;
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
case 'x': case 'x':
@ -779,17 +811,20 @@ print_insn_arg (const char *d,
/* 0 means -1. */ /* 0 means -1. */
if (val == 0) if (val == 0)
val = -1; val = -1;
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
case 'j': case 'j':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "#%d", val+1); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val+1);
break; break;
case 'K': case 'K':
FETCH_ARG (9, val); FETCH_ARG (9, val);
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
case 'M': case 'M':
@ -798,80 +833,108 @@ print_insn_arg (const char *d,
static char *const scalefactor_name[] = { "<<", ">>" }; static char *const scalefactor_name[] = { "<<", ">>" };
FETCH_ARG (1, val); FETCH_ARG (1, val);
(*info->fprintf_func) (info->stream, "%s", scalefactor_name[val]); (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
"%s", scalefactor_name[val]);
} }
else else
{ {
FETCH_ARG (8, val); FETCH_ARG (8, val);
if (val & 0x80) if (val & 0x80)
val = val - 0x100; val = val - 0x100;
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
} }
break; break;
case 'T': case 'T':
FETCH_ARG (4, val); FETCH_ARG (4, val);
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
case 'D': case 'D':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s", reg_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val]);
break; break;
case 'A': case 'A':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s", reg_names[val + 010]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val + 010]);
break; break;
case 'R': case 'R':
FETCH_ARG (4, val); FETCH_ARG (4, val);
(*info->fprintf_func) (info->stream, "%s", reg_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val]);
break; break;
case 'r': case 'r':
FETCH_ARG (4, regno); FETCH_ARG (4, regno);
if (regno > 7) if (regno > 7)
(*info->fprintf_func) (info->stream, "%s@", reg_names[regno]); {
(*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[regno]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
}
else else
(*info->fprintf_func) (info->stream, "@(%s)", reg_names[regno]); {
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[regno]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
}
break; break;
case 'F': case 'F':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%%fp%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%fp%d", val);
break; break;
case 'O': case 'O':
FETCH_ARG (6, val); FETCH_ARG (6, val);
if (val & 0x20) if (val & 0x20)
(*info->fprintf_func) (info->stream, "%s", reg_names[val & 7]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val & 7]);
else else
(*info->fprintf_func) (info->stream, "%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"%d", val);
break; break;
case '+': case '+':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s@+", reg_names[val + 8]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val + 8]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
break; break;
case '-': case '-':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s@-", reg_names[val + 8]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val + 8]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
break; break;
case 'k': case 'k':
if (place == 'k') if (place == 'k')
{ {
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "{%s}", reg_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
(*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
} }
else if (place == 'C') else if (place == 'C')
{ {
FETCH_ARG (7, val); FETCH_ARG (7, val);
if (val > 63) /* This is a signed constant. */ if (val > 63) /* This is a signed constant. */
val -= 128; val -= 128;
(*info->fprintf_func) (info->stream, "{#%d}", val); (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
} }
else else
return PRINT_INSN_ARG_INVALID_OPERAND; return PRINT_INSN_ARG_INVALID_OPERAND;
@ -897,7 +960,8 @@ print_insn_arg (const char *d,
else else
return PRINT_INSN_ARG_INVALID_OP_TABLE; return PRINT_INSN_ARG_INVALID_OP_TABLE;
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
case 'B': case 'B':
@ -936,31 +1000,41 @@ print_insn_arg (const char *d,
NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
FETCH_ARG (3, val1); FETCH_ARG (3, val1);
(*info->fprintf_func) (info->stream, "%s@(%d)", reg_names[val1 + 8], val); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val1 + 8]);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
"%d", val);
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
break; break;
} }
case 's': case 's':
FETCH_ARG (3, val); FETCH_ARG (3, val);
(*info->fprintf_func) (info->stream, "%s", fpcr_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", fpcr_names[val]);
break; break;
case 'e': case 'e':
FETCH_ARG (2, val); FETCH_ARG (2, val);
(*info->fprintf_func) (info->stream, "%%acc%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%acc%d", val);
break; break;
case 'g': case 'g':
FETCH_ARG (1, val); FETCH_ARG (1, val);
(*info->fprintf_func) (info->stream, "%%accext%s", val == 0 ? "01" : "23"); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%accext%s", val == 0 ? "01" : "23");
break; break;
case 'i': case 'i':
FETCH_ARG (2, val); FETCH_ARG (2, val);
if (val == 1) if (val == 1)
(*info->fprintf_func) (info->stream, "<<"); (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
"<<");
else if (val == 3) else if (val == 3)
(*info->fprintf_func) (info->stream, ">>"); (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
">>");
else else
return PRINT_INSN_ARG_INVALID_OPERAND; return PRINT_INSN_ARG_INVALID_OPERAND;
break; break;
@ -971,7 +1045,8 @@ print_insn_arg (const char *d,
if (val < 0) if (val < 0)
return PRINT_INSN_ARG_MEMORY_ERROR; return PRINT_INSN_ARG_MEMORY_ERROR;
if (val != 1) /* Unusual coprocessor ID? */ if (val != 1) /* Unusual coprocessor ID? */
(*info->fprintf_func) (info->stream, "(cpid=%d) ", val); (*info->fprintf_styled_func) (info->stream, dis_style_text,
"(cpid=%d) ", val);
break; break;
case '4': case '4':
@ -1022,28 +1097,41 @@ print_insn_arg (const char *d,
switch (val >> 3) switch (val >> 3)
{ {
case 0: case 0:
(*info->fprintf_func) (info->stream, "%s", reg_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[val]);
break; break;
case 1: case 1:
(*info->fprintf_func) (info->stream, "%s", regname); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", regname);
break; break;
case 2: case 2:
(*info->fprintf_func) (info->stream, "%s@", regname); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", regname);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
break; break;
case 3: case 3:
(*info->fprintf_func) (info->stream, "%s@+", regname); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", regname);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
break; break;
case 4: case 4:
(*info->fprintf_func) (info->stream, "%s@-", regname); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", regname);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
break; break;
case 5: case 5:
NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
(*info->fprintf_func) (info->stream, "%s@(%d)", regname, val); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", regname);
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
"%d", val);
(*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
break; break;
case 6: case 6:
@ -1067,9 +1155,11 @@ print_insn_arg (const char *d,
case 2: case 2:
NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
(*info->fprintf_func) (info->stream, "%%pc@("); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%pc");
(*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
(*info->print_address_func) (addr + val, info); (*info->print_address_func) (addr + val, info);
(*info->fprintf_func) (info->stream, ")"); (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
break; break;
case 3: case 3:
@ -1117,9 +1207,11 @@ print_insn_arg (const char *d,
return PRINT_INSN_ARG_INVALID_OPERAND; return PRINT_INSN_ARG_INVALID_OPERAND;
} }
if (flt_p) /* Print a float? */ if (flt_p) /* Print a float? */
(*info->fprintf_func) (info->stream, "#0e%g", flval); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#0e%g", flval);
else else
(*info->fprintf_func) (info->stream, "#%d", val); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#%d", val);
break; break;
default: default:
@ -1134,7 +1226,7 @@ print_insn_arg (const char *d,
{ {
FETCH_ARG (1, val); FETCH_ARG (1, val);
if (val) if (val)
info->fprintf_func (info->stream, "&"); info->fprintf_styled_func (info->stream, dis_style_text, "&");
} }
break; break;
@ -1150,7 +1242,8 @@ print_insn_arg (const char *d,
p = p1 > p ? p1 : p; p = p1 > p ? p1 : p;
if (val == 0) if (val == 0)
{ {
(*info->fprintf_func) (info->stream, "#0"); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#0");
break; break;
} }
if (*d == 'l') if (*d == 'l')
@ -1170,15 +1263,22 @@ print_insn_arg (const char *d,
int first_regno; int first_regno;
if (doneany) if (doneany)
(*info->fprintf_func) (info->stream, "/"); (*info->fprintf_styled_func) (info->stream, dis_style_text,
"/");
doneany = 1; doneany = 1;
(*info->fprintf_func) (info->stream, "%s", reg_names[regno]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", reg_names[regno]);
first_regno = regno; first_regno = regno;
while (val & (1 << (regno + 1))) while (val & (1 << (regno + 1)))
++regno; ++regno;
if (regno > first_regno) if (regno > first_regno)
(*info->fprintf_func) (info->stream, "-%s", {
reg_names[regno]); (*info->fprintf_styled_func) (info->stream,
dis_style_text, "-");
(*info->fprintf_styled_func) (info->stream,
dis_style_register, "%s",
reg_names[regno]);
}
} }
} }
else if (place == '3') else if (place == '3')
@ -1189,7 +1289,8 @@ print_insn_arg (const char *d,
FETCH_ARG (8, val); FETCH_ARG (8, val);
if (val == 0) if (val == 0)
{ {
(*info->fprintf_func) (info->stream, "#0"); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"#0");
break; break;
} }
if (*d == 'l') if (*d == 'l')
@ -1208,21 +1309,30 @@ print_insn_arg (const char *d,
{ {
int first_regno; int first_regno;
if (doneany) if (doneany)
(*info->fprintf_func) (info->stream, "/"); (*info->fprintf_styled_func) (info->stream, dis_style_text,
"/");
doneany = 1; doneany = 1;
(*info->fprintf_func) (info->stream, "%%fp%d", regno); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%fp%d", regno);
first_regno = regno; first_regno = regno;
while (val & (1 << (regno + 1))) while (val & (1 << (regno + 1)))
++regno; ++regno;
if (regno > first_regno) if (regno > first_regno)
(*info->fprintf_func) (info->stream, "-%%fp%d", regno); {
(*info->fprintf_styled_func) (info->stream,
dis_style_text, "-");
(*info->fprintf_styled_func) (info->stream,
dis_style_register,
"%%fp%d", regno);
}
} }
} }
else if (place == '8') else if (place == '8')
{ {
FETCH_ARG (3, val); FETCH_ARG (3, val);
/* fmoveml for FP status registers. */ /* fmoveml for FP status registers. */
(*info->fprintf_func) (info->stream, "%s", fpcr_names[val]); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", fpcr_names[val]);
} }
else else
return PRINT_INSN_ARG_INVALID_OP_TABLE; return PRINT_INSN_ARG_INVALID_OP_TABLE;
@ -1261,16 +1371,18 @@ print_insn_arg (const char *d,
{ {
int break_reg = ((buffer[3] >> 2) & 7); int break_reg = ((buffer[3] >> 2) & 7);
(*info->fprintf_func) (*info->fprintf_styled_func)
(info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d", (info->stream, dis_style_register,
break_reg); val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
} }
break; break;
default: default:
(*info->fprintf_func) (info->stream, "<mmu register %d>", val); (*info->fprintf_styled_func) (info->stream, dis_style_text,
"<mmu register %d>", val);
} }
if (name) if (name)
(*info->fprintf_func) (info->stream, "%s", name); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%s", name);
} }
break; break;
@ -1280,17 +1392,20 @@ print_insn_arg (const char *d,
FETCH_ARG (5, fc); FETCH_ARG (5, fc);
if (fc == 1) if (fc == 1)
(*info->fprintf_func) (info->stream, "%%dfc"); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%dfc");
else if (fc == 0) else if (fc == 0)
(*info->fprintf_func) (info->stream, "%%sfc"); (*info->fprintf_styled_func) (info->stream, dis_style_register,
"%%sfc");
else else
/* xgettext:c-format */ /* xgettext:c-format */
(*info->fprintf_func) (info->stream, _("<function code %d>"), fc); (*info->fprintf_styled_func) (info->stream, dis_style_text,
_("<function code %d>"), fc);
} }
break; break;
case 'V': case 'V':
(*info->fprintf_func) (info->stream, "%%val"); (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
break; break;
case 't': case 't':
@ -1298,7 +1413,8 @@ print_insn_arg (const char *d,
int level; int level;
FETCH_ARG (3, level); FETCH_ARG (3, level);
(*info->fprintf_func) (info->stream, "%d", level); (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"%d", level);
} }
break; break;
@ -1313,9 +1429,9 @@ print_insn_arg (const char *d,
is_upper = 1; is_upper = 1;
reg &= 0xf; reg &= 0xf;
} }
(*info->fprintf_func) (info->stream, "%s%s", (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
reg_half_names[reg], reg_half_names[reg],
is_upper ? "u" : "l"); is_upper ? "u" : "l");
} }
break; break;
@ -1342,7 +1458,7 @@ match_insn_m68k (bfd_vma memaddr,
struct private *priv = (struct private *) info->private_data; struct private *priv = (struct private *) info->private_data;
bfd_byte *buffer = priv->the_buffer; bfd_byte *buffer = priv->the_buffer;
fprintf_ftype save_printer = info->fprintf_func; fprintf_styled_ftype save_printer = info->fprintf_styled_func;
void (* save_print_address) (bfd_vma, struct disassemble_info *) void (* save_print_address) (bfd_vma, struct disassemble_info *)
= info->print_address_func; = info->print_address_func;
@ -1423,7 +1539,7 @@ match_insn_m68k (bfd_vma memaddr,
save_p = p; save_p = p;
info->print_address_func = dummy_print_address; info->print_address_func = dummy_print_address;
info->fprintf_func = (fprintf_ftype) dummy_printer; info->fprintf_styled_func = dummy_printer;
/* We scan the operands twice. The first time we don't print anything, /* We scan the operands twice. The first time we don't print anything,
but look for errors. */ but look for errors. */
@ -1436,7 +1552,7 @@ match_insn_m68k (bfd_vma memaddr,
else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
|| eaten == PRINT_INSN_ARG_MEMORY_ERROR) || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
{ {
info->fprintf_func = save_printer; info->fprintf_styled_func = save_printer;
info->print_address_func = save_print_address; info->print_address_func = save_print_address;
return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0; return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
} }
@ -1444,26 +1560,26 @@ match_insn_m68k (bfd_vma memaddr,
{ {
/* We must restore the print functions before trying to print the /* We must restore the print functions before trying to print the
error message. */ error message. */
info->fprintf_func = save_printer; info->fprintf_styled_func = save_printer;
info->print_address_func = save_print_address; info->print_address_func = save_print_address;
info->fprintf_func (info->stream, info->fprintf_styled_func (info->stream, dis_style_text,
/* xgettext:c-format */ /* xgettext:c-format */
_("<internal error in opcode table: %s %s>\n"), _("<internal error in opcode table: %s %s>\n"),
best->name, best->args); best->name, best->args);
return 2; return 2;
} }
} }
p = save_p; p = save_p;
info->fprintf_func = save_printer; info->fprintf_styled_func = save_printer;
info->print_address_func = save_print_address; info->print_address_func = save_print_address;
d = args; d = args;
info->fprintf_func (info->stream, "%s", best->name); info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
if (*d) if (*d)
info->fprintf_func (info->stream, " "); info->fprintf_styled_func (info->stream, dis_style_text, " ");
while (*d) while (*d)
{ {
@ -1471,7 +1587,7 @@ match_insn_m68k (bfd_vma memaddr,
d += 2; d += 2;
if (*d && *(d - 2) != 'I' && *d != 'k') if (*d && *(d - 2) != 'I' && *d != 'k')
info->fprintf_func (info->stream, ","); info->fprintf_styled_func (info->stream, dis_style_text, ",");
} }
return p - buffer; return p - buffer;
@ -1638,8 +1754,14 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
} }
if (val == 0) if (val == 0)
/* Handle undefined instructions. */ {
info->fprintf_func (info->stream, ".short 0x%04x", (buffer[0] << 8) + buffer[1]); /* Handle undefined instructions. */
info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
".short");
info->fprintf_styled_func (info->stream, dis_style_text, " ");
info->fprintf_styled_func (info->stream, dis_style_immediate,
"0x%04x", (buffer[0] << 8) + buffer[1]);
}
return val ? val : 2; return val ? val : 2;
} }