X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Ftic4x-dis.c;h=e058fdc9f8a3468284c5aece3d8db3b18ba9fcfa;hb=2c5b6e1a1c406cbe06e2d6f77861764ebd01b9ce;hp=c0f6152beffb2d042cfa3d7ddeefcaa6442ece06;hpb=47b0e7ad8c60ea4b45b22ad5cb376f068991bc88;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/tic4x-dis.c b/opcodes/tic4x-dis.c index c0f6152bef..e058fdc9f8 100644 --- a/opcodes/tic4x-dis.c +++ b/opcodes/tic4x-dis.c @@ -1,27 +1,30 @@ /* Print instructions for the Texas TMS320C[34]X, for GDB and GNU Binutils. - Copyright 2002, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2002-2019 Free Software Foundation, Inc. Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz) - This program is free software; you can redistribute it and/or modify + This file is part of the GNU opcodes library. + + 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 2 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 3, or (at your option) + any later version. - 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. + 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 #include "libiberty.h" -#include "dis-asm.h" +#include "disassemble.h" #include "opcode/tic4x.h" #define TIC4X_DEBUG 0 @@ -117,7 +120,7 @@ tic4x_print_char (struct disassemble_info * info, char ch) } static int -tic4x_print_str (struct disassemble_info *info, char *str) +tic4x_print_str (struct disassemble_info *info, const char *str) { if (info != NULL) (*info->fprintf_func) (info->stream, "%s", str); @@ -134,17 +137,19 @@ tic4x_print_register (struct disassemble_info *info, unsigned long regno) { registertable = xmalloc (sizeof (tic4x_register_t *) * REG_TABLE_SIZE); for (i = 0; i < tic3x_num_registers; i++) - registertable[tic3x_registers[i].regno] = (tic4x_register_t *) (tic3x_registers + i); + registertable[tic3x_registers[i].regno] + = (tic4x_register_t *) (tic3x_registers + i); if (IS_CPU_TIC4X (tic4x_version)) { /* Add C4x additional registers, overwriting any C3x registers if necessary. */ for (i = 0; i < tic4x_num_registers; i++) - registertable[tic4x_registers[i].regno] = - (tic4x_register_t *)(tic4x_registers + i); + registertable[tic4x_registers[i].regno] + = (tic4x_register_t *)(tic4x_registers + i); } } - if ((int) regno > (IS_CPU_TIC4X (tic4x_version) ? TIC4X_REG_MAX : TIC3X_REG_MAX)) + if (regno > (IS_CPU_TIC4X (tic4x_version) ? TIC4X_REG_MAX : TIC3X_REG_MAX) + || registertable[regno] == NULL) return 0; if (info != NULL) (*info->fprintf_func) (info->stream, "%s", registertable[regno]->name); @@ -222,12 +227,12 @@ tic4x_print_immed (struct disassemble_info *info, { case IMMED_SINT: case IMMED_INT: - (*info->fprintf_func) (info->stream, "%d", (long) arg); + (*info->fprintf_func) (info->stream, "%ld", (long) arg); break; case IMMED_SUINT: case IMMED_UINT: - (*info->fprintf_func) (info->stream, "%u", arg); + (*info->fprintf_func) (info->stream, "%lu", arg); break; case IMMED_SFLOAT: @@ -272,7 +277,7 @@ tic4x_print_cond (struct disassemble_info *info, unsigned int cond) if (condtable == NULL) { - condtable = xmalloc (sizeof (tic4x_cond_t *) * 32); + condtable = xcalloc (32, sizeof (tic4x_cond_t *)); for (i = 0; i < tic4x_num_conds; i++) condtable[tic4x_conds[i].cond] = (tic4x_cond_t *)(tic4x_conds + i); } @@ -291,7 +296,7 @@ tic4x_print_indirect (struct disassemble_info *info, unsigned int aregno; unsigned int modn; unsigned int disp; - char *a; + const char *a; aregno = 0; modn = 0; @@ -354,8 +359,8 @@ tic4x_print_op (struct disassemble_info *info, unsigned long pc) { int val; - char *s; - char *parallel = NULL; + const char *s; + const char *parallel = NULL; /* Print instruction name. */ s = p->name; @@ -464,6 +469,7 @@ tic4x_print_op (struct disassemble_info *info, return 0; break; } + /* Fall through. */ case 'J': /* Indirect (short) 8--15. */ if (! tic4x_print_indirect (info, INDIRECT_SHORT, @@ -635,9 +641,9 @@ tic4x_hash_opcode (tic4x_inst_t **optable, const tic4x_inst_t *inst, const unsigned long tic4x_oplevel) { - int j; - int opcode = inst->opcode >> (32 - TIC4X_HASH_SIZE); - int opmask = inst->opmask >> (32 - TIC4X_HASH_SIZE); + unsigned int j; + unsigned int opcode = inst->opcode >> (32 - TIC4X_HASH_SIZE); + unsigned int opmask = inst->opmask >> (32 - TIC4X_HASH_SIZE); /* Use a TIC4X_HASH_SIZE bit index as a hash index. We should have unique entries so there's no point having a linked list @@ -724,7 +730,7 @@ tic4x_disassemble (unsigned long pc, && tic4x_print_op (NULL, instruction, p, pc)) tic4x_print_op (info, instruction, p, pc); else - (*info->fprintf_func) (info->stream, "%08x", instruction); + (*info->fprintf_func) (info->stream, "%08lx", instruction); } else { @@ -736,7 +742,7 @@ tic4x_disassemble (unsigned long pc, break; } if (i == TIC4X_SPESOP_SIZE) - (*info->fprintf_func) (info->stream, "%08x", instruction); + (*info->fprintf_func) (info->stream, "%08lx", instruction); } /* Return size of insn in words. */