/* Disassemble i80960 instructions.
- Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1990-2018 Free Software Foundation, Inc.
-This program 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, 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; see the file COPYING. If not, write to the
-Free Software Foundation, 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; 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 "dis-asm.h"
+#include "disassemble.h"
static const char *const reg_names[] = {
/* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7",
static FILE *stream; /* Output goes here */
static struct disassemble_info *info;
-static void print_addr PARAMS ((bfd_vma));
-static void ctrl PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void cobr PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void reg PARAMS ((unsigned long));
-static int mem PARAMS ((bfd_vma, unsigned long, unsigned long, int));
-static void ea PARAMS ((bfd_vma, int, const char *, const char *, int, unsigned int));
-static void dstop PARAMS ((int, int, int));
-static void regop PARAMS ((int, int, int, int));
-static void invalid PARAMS ((int));
-static int pinsn PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void put_abs PARAMS ((unsigned long, unsigned long));
+static void print_addr (bfd_vma);
+static void ctrl (bfd_vma, unsigned long, unsigned long);
+static void cobr (bfd_vma, unsigned long, unsigned long);
+static void reg (unsigned long);
+static int mem (bfd_vma, unsigned long, unsigned long, int);
+static void ea (bfd_vma, int, const char *, const char *, int, unsigned int);
+static void dstop (int, int, int);
+static void regop (int, int, int, int);
+static void invalid (int);
+static int pinsn (bfd_vma, unsigned long, unsigned long);
+static void put_abs (unsigned long, unsigned long);
/* Print the i960 instruction at address 'memaddr' in debugged memory,
on INFO->STREAM. Returns length of the instruction, in bytes. */
int
-print_insn_i960 (memaddr, info_arg)
- bfd_vma memaddr;
- struct disassemble_info *info_arg;
+print_insn_i960 (bfd_vma memaddr, struct disassemble_info *info_arg)
{
unsigned int word1, word2 = 0xdeadbeef;
bfd_byte buffer[8];
};
static int
-pinsn (memaddr, word1, word2)
- bfd_vma memaddr;
- unsigned long word1, word2;
+pinsn (bfd_vma memaddr, unsigned long word1, unsigned long word2)
{
int instr_len;
-
+
instr_len = 4;
put_abs (word1, word2);
/* CTRL format.. */
static void
-ctrl (memaddr, word1, word2)
- bfd_vma memaddr;
- unsigned long word1;
- unsigned long word2 ATTRIBUTE_UNUSED;
+ctrl (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
{
int i;
static const struct tabent ctrl_tab[] = {
return;
}
- (*info->fprintf_func) (stream, ctrl_tab[i].name);
+ (*info->fprintf_func) (stream, "%s", ctrl_tab[i].name);
if (word1 & 2)
/* Predicts branch not taken. */
(*info->fprintf_func) (stream, ".f");
/* COBR format. */
static void
-cobr (memaddr, word1, word2)
- bfd_vma memaddr;
- unsigned long word1;
- unsigned long word2 ATTRIBUTE_UNUSED;
+cobr (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
{
int src1;
int src2;
int i;
-
+
static const struct tabent cobr_tab[] = {
{ "testno", 1, }, /* 0x20 */
{ "testg", 1, }, /* 0x21 */
return;
}
- (*info->fprintf_func) (stream, cobr_tab[i].name);
+ (*info->fprintf_func) (stream, "%s", cobr_tab[i].name);
/* Predicts branch not taken. */
if (word1 & 2)
/* M1 is 1 */
(*info->fprintf_func) (stream, "%d", src1);
else
- (*info->fprintf_func) (stream, reg_names[src1]);
+ (*info->fprintf_func) (stream, "%s", reg_names[src1]);
if (cobr_tab[i].numops > 1)
{
/* Returns instruction length: 4 or 8. */
static int
-mem (memaddr, word1, word2, noprint)
- bfd_vma memaddr;
- unsigned long word1, word2;
- int noprint; /* If TRUE, return instruction length, but
- don't output any text. */
+mem (bfd_vma memaddr, unsigned long word1, unsigned long word2, int noprint)
{
int i, j;
int len;
int mode;
int offset;
const char *reg1, *reg2, *reg3;
-
+
/* This lookup table is too sparse to make it worth typing in, but not
so large as to make a sparse array necessary. We create the table
at runtime. */
&& ((mode == 5) || (mode >= 12)))
/* With 32-bit displacement. */
len = 8;
- else
+ else
len = 4;
if (noprint)
{ /* MEMA FORMAT */
(*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
- if (mode & 8)
+ if (mode & 8)
(*info->fprintf_func) (stream, "(%s)", reg2);
(*info->fprintf_func)(stream, ",%s", reg1);
/* MEMA FORMAT */
(*info->fprintf_func) (stream, "%s,0x%x", reg1, (unsigned) offset);
- if (mode & 8)
+ if (mode & 8)
(*info->fprintf_func) (stream, "(%s)", reg2);
}
break;
/* REG format. */
static void
-reg (word1)
- unsigned long word1;
+reg (unsigned long word1)
{
int i, j;
int opcode;
at runtime. */
/* NOTE: In this table, the meaning of 'numops' is:
- 1: single operand, which is NOT a destination.
- -1: single operand, which IS a destination.
- 2: 2 operands, the 2nd of which is NOT a destination.
- -2: 2 operands, the 2nd of which IS a destination.
- 3: 3 operands
-
- If an opcode mnemonic begins with "F", it is a floating-point
- opcode (the "F" is not printed). */
+ 1: single operand, which is NOT a destination.
+ -1: single operand, which IS a destination.
+ 2: 2 operands, the 2nd of which is NOT a destination.
+ -2: 2 operands, the 2nd of which IS a destination.
+ 3: 3 operands
+
+ If an opcode mnemonic begins with "F", it is a floating-point
+ opcode (the "F" is not printed). */
static struct tabent *reg_tab;
static const struct sparse_tabent reg_init[] =
fp = 0;
}
- (*info->fprintf_func) (stream, mnemp);
+ (*info->fprintf_func) (stream, "%s", mnemp);
s1 = (word1 >> 5) & 1;
s2 = (word1 >> 6) & 1;
/* Print out effective address for memb instructions. */
static void
-ea (memaddr, mode, reg2, reg3, word1, word2)
- bfd_vma memaddr;
- int mode;
- const char *reg2;
- const char *reg3;
- int word1;
- unsigned int word2;
+ea (bfd_vma memaddr, int mode, const char *reg2, const char *reg3, int word1,
+ unsigned int word2)
{
int scale;
static const int scale_tab[] = { 1, 2, 4, 8, 16 };
/* Register Instruction Operand. */
static void
-regop (mode, spec, reg, fp)
- int mode, spec, reg, fp;
+regop (int mode, int spec, int fp_reg, int fp)
{
if (fp)
{
if (mode == 1)
{
/* FP operand. */
- switch (reg)
+ switch (fp_reg)
{
case 0: (*info->fprintf_func) (stream, "fp0");
break;
else
{
/* Non-FP register. */
- (*info->fprintf_func) (stream, reg_names[reg]);
+ (*info->fprintf_func) (stream, "%s", reg_names[fp_reg]);
}
}
else
if (mode == 1)
{
/* Literal. */
- (*info->fprintf_func) (stream, "%d", reg);
+ (*info->fprintf_func) (stream, "%d", fp_reg);
}
else
{
/* Register. */
if (spec == 0)
- (*info->fprintf_func) (stream, reg_names[reg]);
+ (*info->fprintf_func) (stream, "%s", reg_names[fp_reg]);
else
- (*info->fprintf_func) (stream, "sf%d", reg);
+ (*info->fprintf_func) (stream, "sf%d", fp_reg);
}
}
}
/* Register Instruction Destination Operand. */
static void
-dstop (mode, reg, fp)
- int mode, reg, fp;
+dstop (int mode, int dest_reg, int fp)
{
/* 'dst' operand can't be a literal. On non-FP instructions, register
mode is assumed and "m3" acts as if were "s3"; on FP-instructions,
sf registers are not allowed so m3 acts normally. */
if (fp)
- regop (mode, 0, reg, fp);
+ regop (mode, 0, dest_reg, fp);
else
- regop (0, mode, reg, fp);
+ regop (0, mode, dest_reg, fp);
}
static void
-invalid (word1)
- int word1;
+invalid (int word1)
{
(*info->fprintf_func) (stream, ".word\t0x%08x", (unsigned) word1);
}
static void
-print_addr (a)
- bfd_vma a;
+print_addr (bfd_vma a)
{
(*info->print_address_func) (a, info);
}
static void
-put_abs (word1, word2)
- unsigned long word1 ATTRIBUTE_UNUSED;
- unsigned long word2 ATTRIBUTE_UNUSED;
+put_abs (unsigned long word1 ATTRIBUTE_UNUSED,
+ unsigned long word2 ATTRIBUTE_UNUSED)
{
#ifdef IN_GDB
return;