X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fpdp11-dis.c;h=e9708e639eeac8abdc6475ca6fd6ebad014c12ee;hb=e6b39f6f8e5418ba2a237ef16460c22b49833ca6;hp=850248e2fc09aed6e6a3c0b28176d4445dcab492;hpb=c6843df52be70708585dacee4a13df2c20fc583a;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/pdp11-dis.c b/opcodes/pdp11-dis.c index 850248e2fc..e9708e639e 100644 --- a/opcodes/pdp11-dis.c +++ b/opcodes/pdp11-dis.c @@ -1,50 +1,41 @@ /* Print DEC PDP-11 instructions. - Copyright 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2019 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 -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This file is part of the GNU opcodes library. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ #include "sysdep.h" -#include "dis-asm.h" +#include "disassemble.h" #include "opcode/pdp11.h" #define AFTER_INSTRUCTION "\t" #define OPERAND_SEPARATOR ", " -#define JUMP 0x1000 /* flag that this operand is used in a jump */ +#define JUMP 0x1000 /* Flag that this operand is used in a jump. */ #define FPRINTF (*info->fprintf_func) #define F info->stream -/* sign-extend a 16-bit number in an int */ +/* Sign-extend a 16-bit number in an int. */ #define SIGN_BITS (8 * sizeof (int) - 16) #define sign_extend(x) (((x) << SIGN_BITS) >> SIGN_BITS) -static int read_word PARAMS ((bfd_vma memaddr, int *word, - disassemble_info *info)); -static void print_signed_octal PARAMS ((int n, disassemble_info *info)); -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)); -int print_insn_pdp11 PARAMS ((bfd_vma memaddr, disassemble_info *info)); - static int -read_word (memaddr, word, info) - bfd_vma memaddr; - int *word; - disassemble_info *info; +read_word (bfd_vma memaddr, int *word, disassemble_info *info) { int status; bfd_byte x[2]; @@ -58,9 +49,7 @@ read_word (memaddr, word, info) } static void -print_signed_octal (n, info) - int n; - disassemble_info *info; +print_signed_octal (int n, disassemble_info *info) { if (n < 0) FPRINTF (F, "-%o", -n); @@ -69,11 +58,9 @@ print_signed_octal (n, info) } static void -print_reg (reg, info) - int reg; - disassemble_info *info; +print_reg (int reg, disassemble_info *info) { - /* mask off the addressing mode, if any */ + /* Mask off the addressing mode, if any. */ reg &= 7; switch (reg) @@ -82,23 +69,18 @@ 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 */ } } static void -print_freg (freg, info) - int freg; - disassemble_info *info; +print_freg (int freg, disassemble_info *info) { FPRINTF (F, "fr%d", freg); } static int -print_operand (memaddr, code, info) - bfd_vma *memaddr; - int code; - disassemble_info *info; +print_operand (bfd_vma *memaddr, int code, disassemble_info *info) { int mode = (code >> 3) & 7; int reg = code & 7; @@ -118,6 +100,7 @@ print_operand (memaddr, code, info) if (reg == 7) { int data; + if (read_word (*memaddr, &data, info) < 0) return -1; FPRINTF (F, "$"); @@ -135,6 +118,7 @@ print_operand (memaddr, code, info) if (reg == 7) { int address; + if (read_word (*memaddr, &address, info) < 0) return -1; FPRINTF (F, "*$%o", address); @@ -165,8 +149,11 @@ 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,13 +171,25 @@ print_operand (memaddr, code, info) return 0; } +static int +print_foperand (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. */ int -print_insn_pdp11 (memaddr, info) - bfd_vma memaddr; - disassemble_info *info; +print_insn_pdp11 (bfd_vma memaddr, disassemble_info *info) { bfd_vma start_memaddr = memaddr; int opcode; @@ -215,23 +214,31 @@ print_insn_pdp11 (memaddr, info) switch (OP.type) { case PDP11_OPCODE_NO_OPS: - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); goto done; case PDP11_OPCODE_REG: - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); print_reg (dst, info); goto done; case PDP11_OPCODE_OP: - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); if (strcmp (OP.name, "jmp") == 0) dst |= JUMP; if (print_operand (&memaddr, dst, info) < 0) return -1; goto done; + case PDP11_OPCODE_FOP: + FPRINTF (F, "%s", 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, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); print_reg (src, info); FPRINTF (F, OPERAND_SEPARATOR); @@ -241,17 +248,39 @@ print_insn_pdp11 (memaddr, info) return -1; goto done; case PDP11_OPCODE_REG_OP_REV: - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); if (print_operand (&memaddr, dst, info) < 0) return -1; FPRINTF (F, OPERAND_SEPARATOR); print_reg (src, info); goto done; + case PDP11_OPCODE_AC_FOP: + { + int ac = (opcode & 0xe0) >> 6; + FPRINTF (F, "%s", 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, "%s", 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; - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); print_freg (ac, info); FPRINTF (F, OPERAND_SEPARATOR); @@ -259,8 +288,19 @@ print_insn_pdp11 (memaddr, info) return -1; goto done; } + case PDP11_OPCODE_OP_AC: + { + int ac = (opcode & 0xe0) >> 6; + FPRINTF (F, "%s", 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); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); if (print_operand (&memaddr, src, info) < 0) return -1; @@ -272,7 +312,7 @@ print_insn_pdp11 (memaddr, info) { int displ = (opcode & 0xff) << 8; bfd_vma address = memaddr + (sign_extend (displ) >> 7); - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); (*info->print_address_func) (address, info); goto done; @@ -280,8 +320,9 @@ print_insn_pdp11 (memaddr, info) case PDP11_OPCODE_REG_DISPL: { int displ = (opcode & 0x3f) << 10; - bfd_vma address = memaddr + (sign_extend (displ) >> 9); - FPRINTF (F, OP.name); + bfd_vma address = memaddr - (displ >> 9); + + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); print_reg (src, info); FPRINTF (F, OPERAND_SEPARATOR); @@ -291,7 +332,7 @@ print_insn_pdp11 (memaddr, info) case PDP11_OPCODE_IMM8: { int code = opcode & 0xff; - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); FPRINTF (F, "%o", code); goto done; @@ -299,7 +340,7 @@ print_insn_pdp11 (memaddr, info) case PDP11_OPCODE_IMM6: { int code = opcode & 0x3f; - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); FPRINTF (F, "%o", code); goto done; @@ -307,7 +348,7 @@ print_insn_pdp11 (memaddr, info) case PDP11_OPCODE_IMM3: { int code = opcode & 7; - FPRINTF (F, OP.name); + FPRINTF (F, "%s", OP.name); FPRINTF (F, AFTER_INSTRUCTION); FPRINTF (F, "%o", code); goto done;