This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: handle illegal PDP-11 instructions


This patch makes sure that the PDP-11 disassembler can handle illegal
instructions.  It also replaces all break statements in the switch to
gotos, to break out of the loop which scans the instruction table.

2001-11-22  Lars Brinkhoff  <lars@nocrew.org>

	* pdp11-dis.c (print_insn_pdp11): Handle illegal instructions.
	Also, break out of the loop as soon as an instruction has been
	printed.

Index: opcodes/pdp11-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/pdp11-dis.c,v
retrieving revision 1.2
diff -u -r1.2 pdp11-dis.c
--- pdp11-dis.c	2001/09/20 15:28:25	1.2
+++ pdp11-dis.c	2001/11/22 08:28:17
@@ -216,12 +216,12 @@
 	  {
 	  case PDP11_OPCODE_NO_OPS:
 	    FPRINTF (F, OP.name);
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_REG:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
 	    print_reg (dst, info);
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_OP:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
@@ -229,7 +229,7 @@
 	      dst |= JUMP;
 	    if (print_operand (&memaddr, dst, info) < 0)
 	      return -1;
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_REG_OP:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
@@ -239,7 +239,7 @@
 	      dst |= JUMP;
 	    if (print_operand (&memaddr, dst, info) < 0)
 	      return -1;
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_REG_OP_REV:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
@@ -247,7 +247,7 @@
 	      return -1;
 	    FPRINTF (F, OPERAND_SEPARATOR);
 	    print_reg (src, info);
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_AC_OP:
 	    {
 	      int ac = (opcode & 0xe0) >> 6;
@@ -257,7 +257,7 @@
 	      FPRINTF (F, OPERAND_SEPARATOR);
 	      if (print_operand (&memaddr, dst, info) < 0)
 		return -1;
-	      break;
+	      goto done;
 	    }
 	  case PDP11_OPCODE_OP_OP:
 	    FPRINTF (F, OP.name);
@@ -267,7 +267,7 @@
 	    FPRINTF (F, OPERAND_SEPARATOR);
 	    if (print_operand (&memaddr, dst, info) < 0)
 	      return -1;
-	    break;
+	    goto done;
 	  case PDP11_OPCODE_DISPL:
 	    {
 	      int displ = (opcode & 0xff) << 8;
@@ -275,7 +275,7 @@
 	      FPRINTF (F, OP.name);
 	      FPRINTF (F, AFTER_INSTRUCTION);
 	      (*info->print_address_func) (address, info);
-	      break;
+	      goto done;
 	    }
 	  case PDP11_OPCODE_REG_DISPL:
 	    {
@@ -286,7 +286,7 @@
 	      print_reg (src, info);
 	      FPRINTF (F, OPERAND_SEPARATOR);
 	      (*info->print_address_func) (address, info);
-	      break;
+	      goto done;
 	    }
 	  case PDP11_OPCODE_IMM8:
 	    {
@@ -294,7 +294,7 @@
 	      FPRINTF (F, OP.name);
 	      FPRINTF (F, AFTER_INSTRUCTION);
 	      FPRINTF (F, "%o", code);
-	      break;
+	      goto done;
 	    }
 	  case PDP11_OPCODE_IMM6:
 	    {
@@ -302,7 +302,7 @@
 	      FPRINTF (F, OP.name);
 	      FPRINTF (F, AFTER_INSTRUCTION);
 	      FPRINTF (F, "%o", code);
-	      break;
+	      goto done;
 	    }
 	  case PDP11_OPCODE_IMM3:
 	    {
@@ -310,8 +310,15 @@
 	      FPRINTF (F, OP.name);
 	      FPRINTF (F, AFTER_INSTRUCTION);
 	      FPRINTF (F, "%o", code);
-	      break;
+	      goto done;
 	    }
+	  case PDP11_OPCODE_ILLEGAL:
+	    {
+	      FPRINTF (F, ".word");
+	      FPRINTF (F, AFTER_INSTRUCTION);
+	      FPRINTF (F, "%o", opcode);
+	      goto done;
+	    }
 	  default:
 	    /* TODO: is this a proper way of signalling an error? */
 	    FPRINTF (F, "<internal error: unrecognized instruction type>");
@@ -319,6 +326,7 @@
 	  }
 #undef OP
     }
+ done:
 
   return memaddr - start_memaddr;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]