]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/m68k-dis.c
RISC-V: Support Zabha extension.
[thirdparty/binutils-gdb.git] / opcodes / m68k-dis.c
index ec896433f27076718c7f5e5d5c8b725592119303..bc2f82031c8dbc27c1b9b324c0f7b8988396fc94 100644 (file)
@@ -1,5 +1,5 @@
 /* Print Motorola 68k instructions.
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -213,7 +213,8 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
 \f
 /* This function is used to print to the bit-bucket.  */
 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,
               ...)
 {
@@ -409,7 +410,7 @@ fetch_arg (unsigned char *buffer,
    A similar case exists for the movem instructions where the register
    mask is interpreted differently for different EAs.  */
 
-static bfd_boolean
+static bool
 m68k_valid_ea (char code, int val)
 {
   int mode, mask;
@@ -510,22 +511,39 @@ print_base (int regno, bfd_vma disp, disassemble_info *info)
 {
   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);
     }
   else
     {
-      char buf[50];
+      if (regno == -3)
+       (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                     "%%zpc");
+      else if (regno != -2)
+       (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                     "%s", reg_names[regno]);
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
+      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                   "%" PRIx64, (uint64_t) disp);
+    }
+}
 
-      if (regno == -2)
-       (*info->fprintf_func) (info->stream, "@(");
-      else if (regno == -3)
-       (*info->fprintf_func) (info->stream, "%%zpc@(");
-      else
-       (*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]);
+/* Print the index register of an indexed argument, as encoded in the
+   extension word.  */
 
-      sprintf_vma (buf, disp);
-      (*info->fprintf_func) (info->stream, "%s", buf);
+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));
     }
 }
 
@@ -541,21 +559,12 @@ print_indexed (int basereg,
               disassemble_info *info)
 {
   int word;
-  static char *const scales[] = { "", ":2", ":4", ":8" };
   bfd_vma base_disp;
   bfd_vma outer_disp;
-  char buf[40];
-  char vmabuf[50];
+  bool print_index = true;
 
   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.  */
 
   if ((word & 0x100) == 0)
@@ -566,7 +575,9 @@ print_indexed (int basereg,
       if (basereg == -1)
        base_disp += addr;
       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;
     }
 
@@ -580,7 +591,7 @@ print_indexed (int basereg,
        basereg = -2;
     }
   if (word & 0100)
-    buf[0] = '\0';
+    print_index = false;
   base_disp = 0;
   switch ((word >> 4) & 3)
     {
@@ -597,9 +608,12 @@ print_indexed (int basereg,
   if ((word & 7) == 0)
     {
       print_base (basereg, base_disp, info);
-      if (buf[0] != '\0')
-       (*info->fprintf_func) (info->stream, ",%s", buf);
-      (*info->fprintf_func) (info->stream, ")");
+      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;
     }
 
@@ -615,16 +629,22 @@ print_indexed (int basereg,
     }
 
   print_base (basereg, base_disp, info);
-  if ((word & 4) == 0 && buf[0] != '\0')
+  if ((word & 4) == 0 && print_index)
+    {
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
+      print_index_register (word, info);
+      print_index = false;
+    }
+  (*info->fprintf_styled_func) (info->stream, dis_style_text,
+                               ")@(");
+  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
+                               "%" PRIx64, (uint64_t) outer_disp);
+  if (print_index)
     {
-      (*info->fprintf_func) (info->stream, ",%s", buf);
-      buf[0] = '\0';
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
+      print_index_register (word, info);
     }
-  sprintf_vma (vmabuf, outer_disp);
-  (*info->fprintf_func) (info->stream, ")@(%s", vmabuf);
-  if (buf[0] != '\0')
-    (*info->fprintf_func) (info->stream, ",%s", buf);
-  (*info->fprintf_func) (info->stream, ")");
+  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
 
   return p;
 }
@@ -666,14 +686,17 @@ print_insn_arg (const char *d,
       {
         static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
         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;
       }
 
     case 'a':          /* Address register indirect only. Cf. case '+'.  */
       {
        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;
       }
 
@@ -685,27 +708,27 @@ print_insn_arg (const char *d,
       }
 
     case 'C':
-      (*info->fprintf_func) (info->stream, "%%ccr");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
       break;
 
     case 'S':
-      (*info->fprintf_func) (info->stream, "%%sr");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
       break;
 
     case 'U':
-      (*info->fprintf_func) (info->stream, "%%usp");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
       break;
 
     case 'E':
-      (*info->fprintf_func) (info->stream, "%%acc");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
       break;
 
     case 'G':
-      (*info->fprintf_func) (info->stream, "%%macsr");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
       break;
 
     case 'H':
-      (*info->fprintf_func) (info->stream, "%%mask");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
       break;
 
     case 'J':
@@ -755,7 +778,8 @@ print_insn_arg (const char *d,
            for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
              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;
                }
            if (regno >= 0)
@@ -764,11 +788,12 @@ print_insn_arg (const char *d,
        for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
          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;
            }
        if (regno < 0)
-         (*info->fprintf_func) (info->stream, "0x%x", val);
+         (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
       }
       break;
 
@@ -777,7 +802,8 @@ print_insn_arg (const char *d,
       /* 0 means 8, except for the bkpt instruction... */
       if (val == 0 && d[1] != 's')
        val = 8;
-      (*info->fprintf_func) (info->stream, "#%d", val);
+      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                   "#%d", val);
       break;
 
     case 'x':
@@ -785,17 +811,20 @@ print_insn_arg (const char *d,
       /* 0 means -1.  */
       if (val == 0)
        val = -1;
-      (*info->fprintf_func) (info->stream, "#%d", val);
+      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                   "#%d", val);
       break;
 
     case 'j':
       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;
 
     case 'K':
       FETCH_ARG (9, val);
-      (*info->fprintf_func) (info->stream, "#%d", val);
+      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                   "#%d", val);
       break;
 
     case 'M':
@@ -804,80 +833,108 @@ print_insn_arg (const char *d,
          static char *const scalefactor_name[] = { "<<", ">>" };
 
          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
        {
          FETCH_ARG (8, val);
          if (val & 0x80)
            val = val - 0x100;
-         (*info->fprintf_func) (info->stream, "#%d", val);
+         (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                       "#%d", val);
        }
       break;
 
     case 'T':
       FETCH_ARG (4, val);
-      (*info->fprintf_func) (info->stream, "#%d", val);
+      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                   "#%d", val);
       break;
 
     case 'D':
       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;
 
     case 'A':
       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;
 
     case 'R':
       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;
 
     case 'r':
       FETCH_ARG (4, regno);
       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
-       (*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;
 
     case 'F':
       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;
 
     case 'O':
       FETCH_ARG (6, val);
       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
-       (*info->fprintf_func) (info->stream, "%d", val);
+       (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                     "%d", val);
       break;
 
     case '+':
       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;
 
     case '-':
       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;
 
     case 'k':
       if (place == 'k')
        {
          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')
        {
          FETCH_ARG (7, val);
          if (val > 63)         /* This is a signed constant.  */
            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
        return PRINT_INSN_ARG_INVALID_OPERAND;
@@ -903,7 +960,8 @@ print_insn_arg (const char *d,
       else
        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;
 
     case 'B':
@@ -942,31 +1000,41 @@ print_insn_arg (const char *d,
 
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
        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;
       }
 
     case 's':
       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;
 
     case 'e':
       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;
 
     case 'g':
       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;
 
     case 'i':
       FETCH_ARG (2, val);
       if (val == 1)
-       (*info->fprintf_func) (info->stream, "<<");
+       (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
+                                     "<<");
       else if (val == 3)
-       (*info->fprintf_func) (info->stream, ">>");
+       (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
+                                     ">>");
       else
        return PRINT_INSN_ARG_INVALID_OPERAND;
       break;
@@ -977,7 +1045,8 @@ print_insn_arg (const char *d,
       if (val < 0)
        return PRINT_INSN_ARG_MEMORY_ERROR;
       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;
 
     case '4':
@@ -1028,28 +1097,41 @@ print_insn_arg (const char *d,
       switch (val >> 3)
        {
        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;
 
        case 1:
-         (*info->fprintf_func) (info->stream, "%s", regname);
+         (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                       "%s", regname);
          break;
 
        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;
 
        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;
 
        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;
 
        case 5:
          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;
 
        case 6:
@@ -1073,9 +1155,11 @@ print_insn_arg (const char *d,
 
            case 2:
              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->fprintf_func) (info->stream, ")");
+             (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
              break;
 
            case 3:
@@ -1123,9 +1207,11 @@ print_insn_arg (const char *d,
                  return PRINT_INSN_ARG_INVALID_OPERAND;
              }
              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
-               (*info->fprintf_func) (info->stream, "#%d", val);
+               (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                             "#%d", val);
              break;
 
            default:
@@ -1140,7 +1226,7 @@ print_insn_arg (const char *d,
        {
          FETCH_ARG (1, val);
          if (val)
-           info->fprintf_func (info->stream, "&");
+           info->fprintf_styled_func (info->stream, dis_style_text, "&");
        }
       break;
 
@@ -1156,7 +1242,8 @@ print_insn_arg (const char *d,
            p = p1 > p ? p1 : p;
            if (val == 0)
              {
-               (*info->fprintf_func) (info->stream, "#0");
+               (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                             "#0");
                break;
              }
            if (*d == 'l')
@@ -1176,15 +1263,22 @@ print_insn_arg (const char *d,
                  int first_regno;
 
                  if (doneany)
-                   (*info->fprintf_func) (info->stream, "/");
+                   (*info->fprintf_styled_func) (info->stream, dis_style_text,
+                                                 "/");
                  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;
                  while (val & (1 << (regno + 1)))
                    ++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')
@@ -1195,7 +1289,8 @@ print_insn_arg (const char *d,
            FETCH_ARG (8, val);
            if (val == 0)
              {
-               (*info->fprintf_func) (info->stream, "#0");
+               (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                             "#0");
                break;
              }
            if (*d == 'l')
@@ -1214,21 +1309,30 @@ print_insn_arg (const char *d,
                {
                  int first_regno;
                  if (doneany)
-                   (*info->fprintf_func) (info->stream, "/");
+                   (*info->fprintf_styled_func) (info->stream, dis_style_text,
+                                                 "/");
                  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;
                  while (val & (1 << (regno + 1)))
                    ++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')
          {
            FETCH_ARG (3, val);
            /* 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
          return PRINT_INSN_ARG_INVALID_OP_TABLE;
@@ -1267,16 +1371,18 @@ print_insn_arg (const char *d,
            {
              int break_reg = ((buffer[3] >> 2) & 7);
 
-             (*info->fprintf_func)
-               (info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d",
-                break_reg);
+             (*info->fprintf_styled_func)
+               (info->stream, dis_style_register,
+                val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
            }
            break;
          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)
-         (*info->fprintf_func) (info->stream, "%s", name);
+         (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                       "%s", name);
       }
       break;
 
@@ -1286,17 +1392,20 @@ print_insn_arg (const char *d,
 
        FETCH_ARG (5, fc);
        if (fc == 1)
-         (*info->fprintf_func) (info->stream, "%%dfc");
+         (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                       "%%dfc");
        else if (fc == 0)
-         (*info->fprintf_func) (info->stream, "%%sfc");
+         (*info->fprintf_styled_func) (info->stream, dis_style_register,
+                                       "%%sfc");
        else
          /* 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;
 
     case 'V':
-      (*info->fprintf_func) (info->stream, "%%val");
+      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
       break;
 
     case 't':
@@ -1304,7 +1413,8 @@ print_insn_arg (const char *d,
        int level;
 
        FETCH_ARG (3, level);
-       (*info->fprintf_func) (info->stream, "%d", level);
+       (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+                                     "%d", level);
       }
       break;
 
@@ -1319,9 +1429,9 @@ print_insn_arg (const char *d,
            is_upper = 1;
            reg &= 0xf;
          }
-       (*info->fprintf_func) (info->stream, "%s%s",
-                              reg_half_names[reg],
-                              is_upper ? "u" : "l");
+       (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
+                                     reg_half_names[reg],
+                                     is_upper ? "u" : "l");
       }
       break;
 
@@ -1348,7 +1458,7 @@ match_insn_m68k (bfd_vma memaddr,
 
   struct private *priv = (struct private *) info->private_data;
   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 *)
     = info->print_address_func;
 
@@ -1429,7 +1539,7 @@ match_insn_m68k (bfd_vma memaddr,
 
   save_p = p;
   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,
      but look for errors.  */
@@ -1442,7 +1552,7 @@ match_insn_m68k (bfd_vma memaddr,
       else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
               || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
        {
-         info->fprintf_func = save_printer;
+         info->fprintf_styled_func = save_printer;
          info->print_address_func = save_print_address;
          return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
        }
@@ -1450,26 +1560,26 @@ match_insn_m68k (bfd_vma memaddr,
        {
          /* We must restore the print functions before trying to print the
             error message.  */
-         info->fprintf_func = save_printer;
+         info->fprintf_styled_func = save_printer;
          info->print_address_func = save_print_address;
-         info->fprintf_func (info->stream,
-                             /* xgettext:c-format */
-                             _("<internal error in opcode table: %s %s>\n"),
-                             best->name, best->args);
+         info->fprintf_styled_func (info->stream, dis_style_text,
+                                    /* xgettext:c-format */
+                                    _("<internal error in opcode table: %s %s>\n"),
+                                    best->name, best->args);
          return 2;
        }
     }
 
   p = save_p;
-  info->fprintf_func = save_printer;
+  info->fprintf_styled_func = save_printer;
   info->print_address_func = save_print_address;
 
   d = args;
 
-  info->fprintf_func (info->stream, "%s", best->name);
+  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
 
   if (*d)
-    info->fprintf_func (info->stream, " ");
+    info->fprintf_styled_func (info->stream, dis_style_text, " ");
 
   while (*d)
     {
@@ -1477,7 +1587,7 @@ match_insn_m68k (bfd_vma memaddr,
       d += 2;
 
       if (*d && *(d - 2) != 'I' && *d != 'k')
-       info->fprintf_func (info->stream, ",");
+       info->fprintf_styled_func (info->stream, dis_style_text, ",");
     }
 
   return p - buffer;
@@ -1644,8 +1754,14 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
     }
 
   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;
 }