1999-05-03 09:29:11 +02:00
|
|
|
/* Disassemble D30V instructions.
|
2020-01-01 08:57:01 +01:00
|
|
|
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2007-07-05 11:49:03 +02:00
|
|
|
This file is part of the GNU opcodes library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
2005-07-01 13:16:33 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-05 11:49:03 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
any later version.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2007-07-05 11:49:03 +02:00
|
|
|
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.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
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. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2000-04-14 06:16:58 +02:00
|
|
|
#include "sysdep.h"
|
2012-05-17 17:13:28 +02:00
|
|
|
#include <stdio.h>
|
2001-07-25 03:42:14 +02:00
|
|
|
#include "opcode/d30v.h"
|
Move print_insn_XXX to an opcodes internal header
With the changes done in previous patches, print_insn_XXX functions
don't have to be external visible out of opcodes, because both gdb
and objdump select disassemblers through a single interface.
This patch moves these print_insn_XXX declarations from
include/dis-asm.h to opcodes/disassemble.h, which is a new header
added by this patch.
include:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* dis-asm.h: Move some function declarations to
opcodes/disassemble.h.
opcodes:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* alpha-dis.c: Include disassemble.h, don't include
dis-asm.h.
* avr-dis.c, bfin-dis.c, cr16-dis.c: Likewise.
* crx-dis.c, d10v-dis.c, d30v-dis.c: Likewise.
* disassemble.c, dlx-dis.c, epiphany-dis.c: Likewise.
* fr30-dis.c, ft32-dis.c, h8300-dis.c, h8500-dis.c: Likewise.
* hppa-dis.c, i370-dis.c, i386-dis.c: Likewise.
* i860-dis.c, i960-dis.c, ip2k-dis.c: Likewise.
* iq2000-dis.c, lm32-dis.c, m10200-dis.c: Likewise.
* m10300-dis.c, m32r-dis.c, m68hc11-dis.c: Likewise.
* m68k-dis.c, m88k-dis.c, mcore-dis.c: Likewise.
* metag-dis.c, microblaze-dis.c, mmix-dis.c: Likewise.
* moxie-dis.c, msp430-dis.c, mt-dis.c:
* nds32-dis.c, nios2-dis.c, ns32k-dis.c: Likewise.
* or1k-dis.c, pdp11-dis.c, pj-dis.c: Likewise.
* ppc-dis.c, pru-dis.c, riscv-dis.c: Likewise.
* rl78-dis.c, s390-dis.c, score-dis.c: Likewise.
* sh-dis.c, sh64-dis.c, tic30-dis.c: Likewise.
* tic4x-dis.c, tic54x-dis.c, tic6x-dis.c: Likewise.
* tic80-dis.c, tilegx-dis.c, tilepro-dis.c: Likewise.
* v850-dis.c, vax-dis.c, visium-dis.c: Likewise.
* w65-dis.c, wasm32-dis.c, xc16x-dis.c: Likewise.
* xgate-dis.c, xstormy16-dis.c, xtensa-dis.c: Likewise.
* z80-dis.c, z8k-dis.c: Likewise.
* disassemble.h: New file.
2017-05-24 18:23:52 +02:00
|
|
|
#include "disassemble.h"
|
1999-05-03 09:29:11 +02:00
|
|
|
#include "opintl.h"
|
2019-10-29 11:25:09 +01:00
|
|
|
#include "libiberty.h"
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
#define PC_MASK 0xFFFFFFFF
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
/* Return 0 if lookup fails,
|
|
|
|
1 if found and only one form,
|
|
|
|
2 if found and there are short and long forms. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
static int
|
2005-07-01 13:16:33 +02:00
|
|
|
lookup_opcode (struct d30v_insn *insn, long num, int is_long)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2009-12-11 14:42:17 +01:00
|
|
|
int i = 0, op_index;
|
1999-05-03 09:29:11 +02:00
|
|
|
struct d30v_format *f;
|
2001-07-25 03:42:14 +02:00
|
|
|
struct d30v_opcode *op = (struct d30v_opcode *) d30v_opcode_table;
|
1999-05-03 09:29:11 +02:00
|
|
|
int op1 = (num >> 25) & 0x7;
|
|
|
|
int op2 = (num >> 20) & 0x1f;
|
|
|
|
int mod = (num >> 18) & 0x3;
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
/* Find the opcode. */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ((op->op1 == op1) && (op->op2 == op2))
|
|
|
|
break;
|
|
|
|
op++;
|
|
|
|
}
|
|
|
|
while (op->name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
if (!op || !op->name)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (op->op1 == op1 && op->op2 == op2)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
/* Scan through all the formats for the opcode. */
|
2009-12-11 14:42:17 +01:00
|
|
|
op_index = op->format[i++];
|
2001-07-25 03:42:14 +02:00
|
|
|
do
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2009-12-11 14:42:17 +01:00
|
|
|
f = (struct d30v_format *) &d30v_format_table[op_index];
|
|
|
|
while (f->form == op_index)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
if ((!is_long || f->form >= LONG) && (f->modifier == mod))
|
|
|
|
{
|
|
|
|
insn->form = f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
if (insn->form)
|
|
|
|
break;
|
2001-07-25 03:42:14 +02:00
|
|
|
}
|
2009-12-11 14:42:17 +01:00
|
|
|
while ((op_index = op->format[i++]) != 0);
|
1999-05-03 09:29:11 +02:00
|
|
|
if (insn->form)
|
|
|
|
break;
|
|
|
|
op++;
|
2001-07-25 03:42:14 +02:00
|
|
|
i = 0;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
if (insn->form == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
insn->op = op;
|
|
|
|
insn->ecc = (num >> 28) & 0x7;
|
|
|
|
if (op->format[1])
|
|
|
|
return 2;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
static int
|
2019-12-23 08:32:44 +01:00
|
|
|
extract_value (uint64_t num, const struct d30v_operand *oper, int is_long)
|
2005-07-01 13:16:33 +02:00
|
|
|
{
|
2019-12-23 08:32:44 +01:00
|
|
|
unsigned int val;
|
2005-07-01 13:16:33 +02:00
|
|
|
int shift = 12 - oper->position;
|
2019-12-23 08:32:44 +01:00
|
|
|
unsigned int mask = (0xFFFFFFFF >> (32 - oper->bits));
|
2005-07-01 13:16:33 +02:00
|
|
|
|
|
|
|
if (is_long)
|
|
|
|
{
|
|
|
|
if (oper->bits == 32)
|
|
|
|
/* Piece together 32-bit constant. */
|
|
|
|
val = ((num & 0x3FFFF)
|
|
|
|
| ((num & 0xFF00000) >> 2)
|
|
|
|
| ((num & 0x3F00000000LL) >> 6));
|
|
|
|
else
|
|
|
|
val = (num >> (32 + shift)) & mask;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = (num >> shift) & mask;
|
|
|
|
|
|
|
|
if (oper->flags & OPERAND_SHIFT)
|
|
|
|
val <<= 3;
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
static void
|
2005-07-01 13:16:33 +02:00
|
|
|
print_insn (struct disassemble_info *info,
|
|
|
|
bfd_vma memaddr,
|
2019-12-23 08:32:44 +01:00
|
|
|
uint64_t num,
|
2005-07-01 13:16:33 +02:00
|
|
|
struct d30v_insn *insn,
|
|
|
|
int is_long,
|
|
|
|
int show_ext)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
int val, opnum, need_comma = 0;
|
2019-12-23 08:32:44 +01:00
|
|
|
const struct d30v_operand *oper;
|
2019-12-10 14:20:02 +01:00
|
|
|
int i, match, need_paren = 0, found_control = 0;
|
|
|
|
unsigned int opind = 0;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "%s", insn->op->name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
/* Check for CMP or CMPU. */
|
1999-05-03 09:29:11 +02:00
|
|
|
if (d30v_operand_table[insn->form->operands[0]].flags & OPERAND_NAME)
|
|
|
|
{
|
|
|
|
opind++;
|
2001-07-25 03:42:14 +02:00
|
|
|
val =
|
|
|
|
extract_value (num,
|
2019-12-23 08:32:44 +01:00
|
|
|
&d30v_operand_table[insn->form->operands[0]],
|
2001-07-25 03:42:14 +02:00
|
|
|
is_long);
|
|
|
|
(*info->fprintf_func) (info->stream, "%s", d30v_cc_names[val]);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
/* Add in ".s" or ".l". */
|
1999-05-03 09:29:11 +02:00
|
|
|
if (show_ext == 2)
|
|
|
|
{
|
|
|
|
if (is_long)
|
|
|
|
(*info->fprintf_func) (info->stream, ".l");
|
|
|
|
else
|
|
|
|
(*info->fprintf_func) (info->stream, ".s");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (insn->ecc)
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "/%s", d30v_ecc_names[insn->ecc]);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
(*info->fprintf_func) (info->stream, "\t");
|
|
|
|
|
2019-12-10 14:20:02 +01:00
|
|
|
while (opind < ARRAY_SIZE (insn->form->operands)
|
|
|
|
&& (opnum = insn->form->operands[opind++]) != 0)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
int bits;
|
2005-07-01 13:16:33 +02:00
|
|
|
|
2019-12-23 08:32:44 +01:00
|
|
|
oper = &d30v_operand_table[opnum];
|
1999-05-03 09:29:11 +02:00
|
|
|
bits = oper->bits;
|
|
|
|
if (oper->flags & OPERAND_SHIFT)
|
|
|
|
bits += 3;
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
if (need_comma
|
|
|
|
&& oper->flags != OPERAND_PLUS
|
|
|
|
&& oper->flags != OPERAND_MINUS)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
need_comma = 0;
|
1999-05-03 09:29:11 +02:00
|
|
|
(*info->fprintf_func) (info->stream, ", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oper->flags == OPERAND_ATMINUS)
|
|
|
|
{
|
|
|
|
(*info->fprintf_func) (info->stream, "@-");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (oper->flags == OPERAND_MINUS)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "-");
|
1999-05-03 09:29:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (oper->flags == OPERAND_PLUS)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "+");
|
1999-05-03 09:29:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (oper->flags == OPERAND_ATSIGN)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "@");
|
1999-05-03 09:29:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (oper->flags == OPERAND_ATPAR)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "@(");
|
1999-05-03 09:29:11 +02:00
|
|
|
need_paren = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oper->flags == OPERAND_SPECIAL)
|
|
|
|
continue;
|
|
|
|
|
2001-07-25 03:42:14 +02:00
|
|
|
val = extract_value (num, oper, is_long);
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
if (oper->flags & OPERAND_REG)
|
|
|
|
{
|
|
|
|
match = 0;
|
|
|
|
if (oper->flags & OPERAND_CONTROL)
|
|
|
|
{
|
2019-12-23 08:32:44 +01:00
|
|
|
const struct d30v_operand *oper3
|
|
|
|
= &d30v_operand_table[insn->form->operands[2]];
|
2001-07-25 03:42:14 +02:00
|
|
|
int id = extract_value (num, oper3, is_long);
|
2005-07-01 13:16:33 +02:00
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
found_control = 1;
|
2001-07-25 03:42:14 +02:00
|
|
|
switch (id)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
val |= OPERAND_CONTROL;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
val = OPERAND_CONTROL + MAX_CONTROL_REG + id;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
val |= OPERAND_FLAG;
|
|
|
|
break;
|
|
|
|
default:
|
opcodes error messages
Another patch aimed at making binutils comply with the GNU coding
standard. The generated files require
https://sourceware.org/ml/cgen/2018-q1/msg00004.html
cpu/
* frv.opc: Include opintl.h.
(add_next_to_vliw): Use opcodes_error_handler to print error.
Standardize error message.
(fr500_check_insn_major_constraints, frv_vliw_add_insn): Likewise.
opcodes/
* sysdep.h (opcodes_error_handler): Define.
(_bfd_error_handler): Declare.
* Makefile.am: Remove stray #.
* opc2c.c (main): Remove bogus -l arg handling. Print "DO NOT
EDIT" comment.
* aarch64-dis.c, * arc-dis.c, * arm-dis.c, * avr-dis.c,
* d30v-dis.c, * h8300-dis.c, * mmix-dis.c, * ppc-dis.c,
* riscv-dis.c, * s390-dis.c, * sparc-dis.c, * v850-dis.c: Use
opcodes_error_handler to print errors. Standardize error messages.
* msp430-decode.opc, * nios2-dis.c, * rl78-decode.opc: Likewise,
and include opintl.h.
* nds32-asm.c: Likewise, and include sysdep.h and opintl.h.
* i386-gen.c: Standardize error messages.
* msp430-decode.c, * rl78-decode.c, rx-decode.c: Regenerate.
* Makefile.in: Regenerate.
* epiphany-asm.c, * epiphany-desc.c, * epiphany-dis.c,
* epiphany-ibld.c, * fr30-asm.c, * fr30-desc.c, * fr30-dis.c,
* fr30-ibld.c, * frv-asm.c, * frv-desc.c, * frv-dis.c, * frv-ibld.c,
* frv-opc.c, * ip2k-asm.c, * ip2k-desc.c, * ip2k-dis.c, * ip2k-ibld.c,
* iq2000-asm.c, * iq2000-desc.c, * iq2000-dis.c, * iq2000-ibld.c,
* lm32-asm.c, * lm32-desc.c, * lm32-dis.c, * lm32-ibld.c,
* m32c-asm.c, * m32c-desc.c, * m32c-dis.c, * m32c-ibld.c,
* m32r-asm.c, * m32r-desc.c, * m32r-dis.c, * m32r-ibld.c,
* mep-asm.c, * mep-desc.c, * mep-dis.c, * mep-ibld.c, * mt-asm.c,
* mt-desc.c, * mt-dis.c, * mt-ibld.c, * or1k-asm.c, * or1k-desc.c,
* or1k-dis.c, * or1k-ibld.c, * xc16x-asm.c, * xc16x-desc.c,
* xc16x-dis.c, * xc16x-ibld.c, * xstormy16-asm.c, * xstormy16-desc.c,
* xstormy16-dis.c, * xstormy16-ibld.c: Regenerate.
2018-03-01 22:53:50 +01:00
|
|
|
/* xgettext: c-format */
|
|
|
|
opcodes_error_handler (_("illegal id (%d)"), id);
|
|
|
|
abort ();
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (oper->flags & OPERAND_ACC)
|
|
|
|
val |= OPERAND_ACC;
|
|
|
|
else if (oper->flags & OPERAND_FLAG)
|
|
|
|
val |= OPERAND_FLAG;
|
2001-07-25 03:42:14 +02:00
|
|
|
for (i = 0; i < reg_name_cnt (); i++)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
if (val == pre_defined_registers[i].value)
|
|
|
|
{
|
|
|
|
if (pre_defined_registers[i].pname)
|
|
|
|
(*info->fprintf_func)
|
2001-07-25 03:42:14 +02:00
|
|
|
(info->stream, "%s", pre_defined_registers[i].pname);
|
1999-05-03 09:29:11 +02:00
|
|
|
else
|
|
|
|
(*info->fprintf_func)
|
2001-07-25 03:42:14 +02:00
|
|
|
(info->stream, "%s", pre_defined_registers[i].name);
|
|
|
|
match = 1;
|
1999-05-03 09:29:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-07-25 03:42:14 +02:00
|
|
|
if (match == 0)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
/* This would only get executed if a register was not in
|
|
|
|
the register table. */
|
1999-05-03 09:29:11 +02:00
|
|
|
(*info->fprintf_func)
|
2001-07-25 03:42:14 +02:00
|
|
|
(info->stream, _("<unknown register %d>"), val & 0x3F);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
}
|
2000-03-03 00:01:40 +01:00
|
|
|
/* repeati has a relocation, but its first argument is a plain
|
|
|
|
immediate. OTOH instructions like djsri have a pc-relative
|
2001-10-29 23:43:32 +01:00
|
|
|
delay target, but an absolute jump target. Therefore, a test
|
2000-03-03 00:01:40 +01:00
|
|
|
of insn->op->reloc_flag is not specific enough; we must test
|
|
|
|
if the actual operand we are handling now is pc-relative. */
|
|
|
|
else if (oper->flags & OPERAND_PCREL)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2000-03-03 00:01:40 +01:00
|
|
|
int neg = 0;
|
2001-07-25 03:42:14 +02:00
|
|
|
|
2000-03-03 00:01:40 +01:00
|
|
|
/* IMM6S3 is unsigned. */
|
|
|
|
if (oper->flags & OPERAND_SIGNED || bits == 32)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2020-01-01 09:16:43 +01:00
|
|
|
unsigned int sign = 1u << (bits - 1);
|
|
|
|
if (val & sign)
|
2000-03-03 00:01:40 +01:00
|
|
|
{
|
2020-01-01 09:16:43 +01:00
|
|
|
val = -val & (sign + sign - 1);
|
2000-03-03 00:01:40 +01:00
|
|
|
neg = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (neg)
|
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "-%x\t(", val);
|
2000-03-03 00:01:40 +01:00
|
|
|
(*info->print_address_func) ((memaddr - val) & PC_MASK, info);
|
|
|
|
(*info->fprintf_func) (info->stream, ")");
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
2000-03-03 00:01:40 +01:00
|
|
|
else
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "%x\t(", val);
|
2000-03-03 00:01:40 +01:00
|
|
|
(*info->print_address_func) ((memaddr + val) & PC_MASK, info);
|
|
|
|
(*info->fprintf_func) (info->stream, ")");
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (insn->op->reloc_flag == RELOC_ABS)
|
|
|
|
{
|
|
|
|
(*info->print_address_func) (val, info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (oper->flags & OPERAND_SIGNED)
|
|
|
|
{
|
2020-01-01 09:16:43 +01:00
|
|
|
unsigned int sign = 1u << (bits - 1);
|
2005-07-01 13:16:33 +02:00
|
|
|
|
2020-01-01 09:16:43 +01:00
|
|
|
if (val & sign)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2020-01-01 09:16:43 +01:00
|
|
|
val = -val & (sign + sign - 1);
|
1999-05-03 09:29:11 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "-");
|
|
|
|
}
|
|
|
|
}
|
2001-07-25 03:42:14 +02:00
|
|
|
(*info->fprintf_func) (info->stream, "0x%x", val);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
2001-07-25 03:42:14 +02:00
|
|
|
/* If there is another operand, then write a comma and space. */
|
2019-12-10 14:20:02 +01:00
|
|
|
if (opind < ARRAY_SIZE (insn->form->operands)
|
2019-10-29 11:25:09 +01:00
|
|
|
&& insn->form->operands[opind]
|
|
|
|
&& !(found_control && opind == 2))
|
1999-05-03 09:29:11 +02:00
|
|
|
need_comma = 1;
|
|
|
|
}
|
|
|
|
if (need_paren)
|
|
|
|
(*info->fprintf_func) (info->stream, ")");
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
int
|
|
|
|
print_insn_d30v (bfd_vma memaddr, struct disassemble_info *info)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2005-07-01 13:16:33 +02:00
|
|
|
int status, result;
|
|
|
|
bfd_byte buffer[12];
|
2019-12-23 08:32:44 +01:00
|
|
|
uint32_t in1, in2;
|
2005-07-01 13:16:33 +02:00
|
|
|
struct d30v_insn insn;
|
2019-12-23 08:32:44 +01:00
|
|
|
uint64_t num;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
insn.form = NULL;
|
|
|
|
|
|
|
|
info->bytes_per_line = 8;
|
|
|
|
info->bytes_per_chunk = 4;
|
|
|
|
info->display_endian = BFD_ENDIAN_BIG;
|
|
|
|
|
|
|
|
status = (*info->read_memory_func) (memaddr, buffer, 4, info);
|
|
|
|
if (status != 0)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2005-07-01 13:16:33 +02:00
|
|
|
(*info->memory_error_func) (status, memaddr, info);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
in1 = bfd_getb32 (buffer);
|
|
|
|
|
|
|
|
status = (*info->read_memory_func) (memaddr + 4, buffer, 4, info);
|
|
|
|
if (status != 0)
|
|
|
|
{
|
|
|
|
info->bytes_per_line = 8;
|
|
|
|
if (!(result = lookup_opcode (&insn, in1, 0)))
|
2019-12-23 08:32:44 +01:00
|
|
|
(*info->fprintf_func) (info->stream, ".long\t0x%x", in1);
|
2005-07-01 13:16:33 +02:00
|
|
|
else
|
2019-12-23 08:32:44 +01:00
|
|
|
print_insn (info, memaddr, (uint64_t) in1, &insn, 0, result);
|
2005-07-01 13:16:33 +02:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
in2 = bfd_getb32 (buffer);
|
|
|
|
|
|
|
|
if (in1 & in2 & FM01)
|
|
|
|
{
|
|
|
|
/* LONG instruction. */
|
|
|
|
if (!(result = lookup_opcode (&insn, in1, 1)))
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2019-12-23 08:32:44 +01:00
|
|
|
(*info->fprintf_func) (info->stream, ".long\t0x%x,0x%x", in1, in2);
|
2005-07-01 13:16:33 +02:00
|
|
|
return 8;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
2019-12-23 08:32:44 +01:00
|
|
|
num = (uint64_t) in1 << 32 | in2;
|
2005-07-01 13:16:33 +02:00
|
|
|
print_insn (info, memaddr, num, &insn, 1, result);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
else
|
2005-07-01 13:16:33 +02:00
|
|
|
{
|
|
|
|
num = in1;
|
|
|
|
if (!(result = lookup_opcode (&insn, in1, 0)))
|
2019-12-23 08:32:44 +01:00
|
|
|
(*info->fprintf_func) (info->stream, ".long\t0x%x", in1);
|
2005-07-01 13:16:33 +02:00
|
|
|
else
|
|
|
|
print_insn (info, memaddr, num, &insn, 0, result);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
switch (((in1 >> 31) << 1) | (in2 >> 31))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
(*info->fprintf_func) (info->stream, "\t||\t");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
(*info->fprintf_func) (info->stream, "\t->\t");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
(*info->fprintf_func) (info->stream, "\t<-\t");
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
insn.form = NULL;
|
|
|
|
num = in2;
|
|
|
|
if (!(result = lookup_opcode (&insn, in2, 0)))
|
2019-12-23 08:32:44 +01:00
|
|
|
(*info->fprintf_func) (info->stream, ".long\t0x%x", in2);
|
2005-07-01 13:16:33 +02:00
|
|
|
else
|
|
|
|
print_insn (info, memaddr, num, &insn, 0, result);
|
|
|
|
}
|
|
|
|
return 8;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|