X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fmmix-dis.c;h=6ec50bf27d26d245af72210520453c9e32936ff4;hb=8069955ee0dbcf6813218a968828afb838c676d9;hp=c81e679f4e1164ce6a524ce1518f1c72454e091c;hpb=2ee563b53258d390d7446e90a67f465d504ae44c;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/mmix-dis.c b/opcodes/mmix-dis.c index c81e679f4e..6ec50bf27d 100644 --- a/opcodes/mmix-dis.c +++ b/opcodes/mmix-dis.c @@ -1,26 +1,26 @@ /* mmix-dis.c -- Disassemble MMIX instructions. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000-2017 Free Software Foundation, Inc. Written by Hans-Peter Nilsson (hp@bitrange.com) -This file is part of GDB and the GNU binutils. + This file is part of the GNU opcodes library. -GDB and the GNU binutils are free software; you can redistribute -them and/or modify them under the terms of the GNU General Public -License as published by the Free Software Foundation; either version 2, -or (at your option) any later version. + 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. -GDB and the GNU binutils are distributed in the hope that they -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. + 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 file; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this file; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ +#include "sysdep.h" #include -#include -#include #include "opcode/mmix.h" #include "dis-asm.h" #include "libiberty.h" @@ -37,14 +37,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * } \ while (0) -#define FATAL_DEBUG \ - do \ - { \ - fprintf (stderr, \ - _("Internal: Non-debugged code (test-case missing): %s:%d"), \ - __FILE__, __LINE__); \ - abort (); \ - } \ +#define FATAL_DEBUG \ + do \ + { \ + fprintf (stderr, \ + _("Internal: Non-debugged code (test-case missing): %s:%d"),\ + __FILE__, __LINE__); \ + abort (); \ + } \ while (0) #define ROUND_MODE(n) \ @@ -66,21 +66,16 @@ struct mmix_dis_info char basic_reg_name[256][sizeof ("$255")]; }; -static boolean initialize_mmix_dis_info PARAMS ((struct disassemble_info *)); -static const struct mmix_opcode *get_opcode PARAMS ((unsigned long)); - - /* Initialize a target-specific array in INFO. */ -static boolean -initialize_mmix_dis_info (info) - struct disassemble_info *info; +static bfd_boolean +initialize_mmix_dis_info (struct disassemble_info *info) { struct mmix_dis_info *minfop = malloc (sizeof (struct mmix_dis_info)); - int i; + long i; if (minfop == NULL) - return false; + return FALSE; memset (minfop, 0, sizeof (*minfop)); @@ -102,12 +97,12 @@ initialize_mmix_dis_info (info) long symsize = bfd_get_symtab_upper_bound (abfd); asymbol **syms = malloc (symsize); long nsyms; - long i; if (syms == NULL) - { FATAL_DEBUG; + { + FATAL_DEBUG; free (minfop); - return false; + return FALSE; } nsyms = bfd_canonicalize_symtab (abfd, syms); @@ -128,7 +123,7 @@ initialize_mmix_dis_info (info) for (i = 0; i < 256; i++) if (minfop->reg_name[i] == NULL) { - sprintf (minfop->basic_reg_name[i], "$%d", i); + sprintf (minfop->basic_reg_name[i], "$%ld", i); minfop->reg_name[i] = minfop->basic_reg_name[i]; } @@ -136,8 +131,8 @@ initialize_mmix_dis_info (info) for (i = 0; mmix_spec_regs[i].name != NULL; i++) minfop->spec_reg_name[mmix_spec_regs[i].number] = mmix_spec_regs[i].name; - info->private_data = (PTR) minfop; - return true; + info->private_data = (void *) minfop; + return TRUE; } /* A table indexed by the first byte is constructed as we disassemble each @@ -148,12 +143,12 @@ initialize_mmix_dis_info (info) "further entry" will just show that there was no other match. */ static const struct mmix_opcode * -get_opcode (insn) - unsigned long insn; +get_opcode (unsigned long insn) { static const struct mmix_opcode **opcodes = NULL; const struct mmix_opcode *opcodep = mmix_opcodes; unsigned int opcode_part = (insn >> 24) & 255; + if (opcodes == NULL) opcodes = xcalloc (256, sizeof (struct mmix_opcode *)); @@ -211,6 +206,7 @@ get_opcode (insn) case mmix_operands_roundregs: { int midbyte = (insn >> 8) & 255; + if (midbyte <= 4) return opcodep; } @@ -246,9 +242,7 @@ get_opcode (insn) /* The main disassembly function. */ int -print_insn_mmix (memaddr, info) - bfd_vma memaddr; - struct disassemble_info *info; +print_insn_mmix (bfd_vma memaddr, struct disassemble_info *info) { unsigned char buffer[4]; unsigned long insn;