opcodes: style m68k disassembler output

Message ID 877cwere3q.fsf@igel.home
State Accepted
Headers
Series opcodes: style m68k disassembler output |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Andreas Schwab Feb. 18, 2023, 7:02 p.m. UTC
  ---
 opcodes/m68k-dis.c | 354 ++++++++++++++++++++++++++++++---------------
 1 file changed, 238 insertions(+), 116 deletions(-)
  

Comments

Nick Clifton Feb. 20, 2023, 12:55 p.m. UTC | #1
Hi Andreas,

>   opcodes/m68k-dis.c | 354 ++++++++++++++++++++++++++++++---------------
>   1 file changed, 238 insertions(+), 116 deletions(-)

Approved - please apply.

Cheers
   Nick
  

Patch

diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c
index a416fbe7cfa..fb384640763 100644
--- a/opcodes/m68k-dis.c
+++ b/opcodes/m68k-dis.c
@@ -213,7 +213,8 @@  fetch_data (struct disassemble_info *info, bfd_byte *addr)
 
 /* 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,
 	       ...)
 {
@@ -510,18 +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
     {
-      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]);
-      (*info->fprintf_func) (info->stream, "%" PRIx64, (uint64_t) disp);
+      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);
+    }
+}
+
+/* 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)
 {
   int word;
-  static char *const scales[] = { "", ":2", ":4", ":8" };
   bfd_vma base_disp;
   bfd_vma outer_disp;
-  char buf[40];
+  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)
@@ -561,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;
     }
 
@@ -575,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)
     {
@@ -592,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;
     }
 
@@ -610,15 +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_func) (info->stream, ",%s", buf);
-      buf[0] = '\0';
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
+      print_index_register (word, info);
+      print_index = false;
     }
-  (*info->fprintf_func) (info->stream, ")@(%" PRIx64, (uint64_t) outer_disp);
-  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,
+				")@(");
+  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
+				"%" 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;
 }
@@ -660,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;
       }
 
@@ -679,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':
@@ -749,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)
@@ -758,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;
 
@@ -771,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':
@@ -779,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':
@@ -798,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;
@@ -897,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':
@@ -936,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;
@@ -971,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':
@@ -1022,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:
@@ -1067,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:
@@ -1117,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:
@@ -1134,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;
 
@@ -1150,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')
@@ -1170,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')
@@ -1189,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')
@@ -1208,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;
@@ -1261,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;
 
@@ -1280,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':
@@ -1298,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;
 
@@ -1313,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;
 
@@ -1342,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;
 
@@ -1423,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.  */
@@ -1436,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;
 	}
@@ -1444,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)
     {
@@ -1471,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;
@@ -1638,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;
 }