cpu/
[deliverable/binutils-gdb.git] / opcodes / pdp11-dis.c
index 3c75c4816142a6f2dd98fe7bc12dda05453728c9..4f5bf84aead8ad8af5451ed78bd20dc9ac73d87d 100644 (file)
@@ -1,5 +1,5 @@
 /* Print DEC PDP-11 instructions.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
 This file is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -38,6 +38,8 @@ static void print_reg PARAMS ((int reg, disassemble_info *info));
 static void print_freg PARAMS ((int freg, disassemble_info *info));
 static int print_operand PARAMS ((bfd_vma *memaddr, int code,
                                  disassemble_info *info));
+static int print_foperand PARAMS ((bfd_vma *memaddr, int code,
+                                   disassemble_info *info));
 int print_insn_pdp11 PARAMS ((bfd_vma memaddr, disassemble_info *info));
 
 static int
@@ -82,7 +84,7 @@ print_reg (reg, info)
                FPRINTF (F, "r%d", reg); break;
     case 6:    FPRINTF (F, "sp"); break;
     case 7:    FPRINTF (F, "pc"); break;
-    default:   /* error */
+    default: ; /* error */
     }
 }
 
@@ -165,8 +167,10 @@ print_operand (memaddr, code, info)
       if (reg == 7)
        {
          bfd_vma address = *memaddr + sign_extend (disp);
+         if (mode == 7)
+           FPRINTF (F, "*");
          if (!(code & JUMP))
-           FPRINTF (F, "*$");
+           FPRINTF (F, "$");
          (*info->print_address_func) (address, info);
        }
       else
@@ -184,6 +188,23 @@ print_operand (memaddr, code, info)
   return 0;
 }
 
+static int
+print_foperand (memaddr, code, info)
+     bfd_vma *memaddr;
+     int code;
+     disassemble_info *info;
+{
+  int mode = (code >> 3) & 7;
+  int reg = code & 7;
+
+  if (mode == 0)
+    print_freg (reg, info);
+  else
+    return print_operand (memaddr, code, info);
+
+  return 0;
+}
+
 /* Print the PDP-11 instruction at address MEMADDR in debugged memory,
    on INFO->STREAM.  Returns length of the instruction, in bytes.  */
 
@@ -216,12 +237,12 @@ print_insn_pdp11 (memaddr, info)
          {
          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 +250,15 @@ print_insn_pdp11 (memaddr, info)
              dst |= JUMP;
            if (print_operand (&memaddr, dst, info) < 0)
              return -1;
-           break;
+           goto done;
+         case PDP11_OPCODE_FOP:
+           FPRINTF (F, OP.name);
+           FPRINTF (F, AFTER_INSTRUCTION);
+           if (strcmp (OP.name, "jmp") == 0)
+             dst |= JUMP;
+           if (print_foperand (&memaddr, dst, info) < 0)
+             return -1;
+           goto done;
          case PDP11_OPCODE_REG_OP:
            FPRINTF (F, OP.name);
            FPRINTF (F, AFTER_INSTRUCTION);
@@ -239,7 +268,7 @@ print_insn_pdp11 (memaddr, info)
              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 +276,29 @@ print_insn_pdp11 (memaddr, info)
              return -1;
            FPRINTF (F, OPERAND_SEPARATOR);
            print_reg (src, info);
-           break;
+           goto done;
+         case PDP11_OPCODE_AC_FOP:
+           {
+             int ac = (opcode & 0xe0) >> 6;
+             FPRINTF (F, OP.name);
+             FPRINTF (F, AFTER_INSTRUCTION);
+             print_freg (ac, info);
+             FPRINTF (F, OPERAND_SEPARATOR);
+             if (print_foperand (&memaddr, dst, info) < 0)
+               return -1;
+             goto done;
+           }
+         case PDP11_OPCODE_FOP_AC:
+           {
+             int ac = (opcode & 0xe0) >> 6;
+             FPRINTF (F, OP.name);
+             FPRINTF (F, AFTER_INSTRUCTION);
+             if (print_foperand (&memaddr, dst, info) < 0)
+               return -1;
+             FPRINTF (F, OPERAND_SEPARATOR);
+             print_freg (ac, info);
+             goto done;
+           }
          case PDP11_OPCODE_AC_OP:
            {
              int ac = (opcode & 0xe0) >> 6;
@@ -257,7 +308,18 @@ print_insn_pdp11 (memaddr, info)
              FPRINTF (F, OPERAND_SEPARATOR);
              if (print_operand (&memaddr, dst, info) < 0)
                return -1;
-             break;
+             goto done;
+           }
+         case PDP11_OPCODE_OP_AC:
+           {
+             int ac = (opcode & 0xe0) >> 6;
+             FPRINTF (F, OP.name);
+             FPRINTF (F, AFTER_INSTRUCTION);
+             if (print_operand (&memaddr, dst, info) < 0)
+               return -1;
+             FPRINTF (F, OPERAND_SEPARATOR);
+             print_freg (ac, info);
+             goto done;
            }
          case PDP11_OPCODE_OP_OP:
            FPRINTF (F, OP.name);
@@ -267,7 +329,7 @@ print_insn_pdp11 (memaddr, info)
            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 +337,7 @@ print_insn_pdp11 (memaddr, info)
              FPRINTF (F, OP.name);
              FPRINTF (F, AFTER_INSTRUCTION);
              (*info->print_address_func) (address, info);
-             break;
+             goto done;
            }
          case PDP11_OPCODE_REG_DISPL:
            {
@@ -286,7 +348,7 @@ print_insn_pdp11 (memaddr, info)
              print_reg (src, info);
              FPRINTF (F, OPERAND_SEPARATOR);
              (*info->print_address_func) (address, info);
-             break;
+             goto done;
            }
          case PDP11_OPCODE_IMM8:
            {
@@ -294,7 +356,7 @@ print_insn_pdp11 (memaddr, info)
              FPRINTF (F, OP.name);
              FPRINTF (F, AFTER_INSTRUCTION);
              FPRINTF (F, "%o", code);
-             break;
+             goto done;
            }
          case PDP11_OPCODE_IMM6:
            {
@@ -302,7 +364,7 @@ print_insn_pdp11 (memaddr, info)
              FPRINTF (F, OP.name);
              FPRINTF (F, AFTER_INSTRUCTION);
              FPRINTF (F, "%o", code);
-             break;
+             goto done;
            }
          case PDP11_OPCODE_IMM3:
            {
@@ -310,7 +372,14 @@ print_insn_pdp11 (memaddr, info)
              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? */
@@ -319,6 +388,7 @@ print_insn_pdp11 (memaddr, info)
          }
 #undef OP
     }
+ done:
 
   return memaddr - start_memaddr;
 }
This page took 0.026042 seconds and 4 git commands to generate.