1999-05-03 15:29:11 +08:00
|
|
|
/* Disassemble h8300 instructions.
|
2020-01-01 15:57:01 +08:00
|
|
|
Copyright (C) 1993-2020 Free Software Foundation, Inc.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2007-07-05 17:49:03 +08:00
|
|
|
This file is part of the GNU opcodes library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
2004-07-23 00:52:43 +08:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-05 17:49:03 +08:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
any later version.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2007-07-05 17:49:03 +08: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 15:29:11 +08:00
|
|
|
|
2004-07-23 00:52:43 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-07-01 19:16:33 +08:00
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
#define DEFINE_TABLE
|
|
|
|
|
2000-04-14 12:16:58 +08:00
|
|
|
#include "sysdep.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
#define h8_opcodes h8ops
|
|
|
|
#include "opcode/h8300.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-25 00:23:52 +08:00
|
|
|
#include "disassemble.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
#include "opintl.h"
|
2002-11-19 00:52:46 +08:00
|
|
|
#include "libiberty.h"
|
|
|
|
|
|
|
|
struct h8_instruction
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
const struct h8_opcode *opcode;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct h8_instruction *h8_instructions;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* Run through the opcodes and sort them into order to make them easy
|
2000-06-02 02:19:59 +08:00
|
|
|
to disassemble. */
|
2003-06-04 05:32:52 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
static void
|
2005-07-01 19:16:33 +08:00
|
|
|
bfd_h8_disassemble_init (void)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2002-11-19 00:52:46 +08:00
|
|
|
unsigned int nopcodes;
|
|
|
|
const struct h8_opcode *p;
|
|
|
|
struct h8_instruction *pi;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2002-11-19 00:52:46 +08:00
|
|
|
nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
h8_instructions = xmalloc (nopcodes * sizeof (struct h8_instruction));
|
2002-11-19 00:52:46 +08:00
|
|
|
|
|
|
|
for (p = h8_opcodes, pi = h8_instructions; p->name; p++, pi++)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
/* Just make sure there are an even number of nibbles in it, and
|
2000-06-02 02:19:59 +08:00
|
|
|
that the count is the same as the length. */
|
2003-06-04 05:32:52 +08:00
|
|
|
for (i = 0; p->data.nib[i] != (op_type) E; i++)
|
2000-06-13 06:23:25 +08:00
|
|
|
;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (i & 1)
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
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-02 05:53:50 +08:00
|
|
|
/* xgettext:c-format */
|
|
|
|
opcodes_error_handler (_("internal error, h8_disassemble_init"));
|
2003-06-04 05:32:52 +08:00
|
|
|
abort ();
|
|
|
|
}
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2002-11-19 00:52:46 +08:00
|
|
|
pi->length = i / 2;
|
|
|
|
pi->opcode = p;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2002-11-19 00:52:46 +08:00
|
|
|
|
|
|
|
/* Add entry for the NULL vector terminator. */
|
|
|
|
pi->length = 0;
|
|
|
|
pi->opcode = p;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
static void
|
2005-07-01 19:16:33 +08:00
|
|
|
extract_immediate (FILE *stream,
|
|
|
|
op_type looking_for,
|
|
|
|
int thisnib,
|
|
|
|
unsigned char *data,
|
|
|
|
int *cst,
|
|
|
|
int *len,
|
|
|
|
const struct h8_opcode *q)
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
|
|
|
switch (looking_for & SIZE)
|
|
|
|
{
|
|
|
|
case L_2:
|
|
|
|
*len = 2;
|
|
|
|
*cst = thisnib & 3;
|
|
|
|
|
|
|
|
/* DISP2 special treatment. */
|
|
|
|
if ((looking_for & MODE) == DISP)
|
|
|
|
{
|
2005-07-01 19:16:33 +08:00
|
|
|
if (OP_KIND (q->how) == O_MOVAB
|
|
|
|
|| OP_KIND (q->how) == O_MOVAW
|
|
|
|
|| OP_KIND (q->how) == O_MOVAL)
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
|
|
|
/* Handling for mova insn. */
|
2005-07-01 19:16:33 +08:00
|
|
|
switch (q->args.nib[0] & MODE)
|
|
|
|
{
|
|
|
|
case INDEXB:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case INDEXW:
|
|
|
|
*cst *= 2;
|
|
|
|
break;
|
|
|
|
case INDEXL:
|
|
|
|
*cst *= 4;
|
|
|
|
break;
|
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Handling for non-mova insn. */
|
2005-07-01 19:16:33 +08:00
|
|
|
switch (OP_SIZE (q->how))
|
|
|
|
{
|
|
|
|
default: break;
|
|
|
|
case SW:
|
|
|
|
*cst *= 2;
|
|
|
|
break;
|
|
|
|
case SL:
|
|
|
|
*cst *= 4;
|
|
|
|
break;
|
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case L_8:
|
|
|
|
*len = 8;
|
|
|
|
*cst = data[0];
|
|
|
|
break;
|
|
|
|
case L_16:
|
|
|
|
case L_16U:
|
|
|
|
*len = 16;
|
|
|
|
*cst = (data[0] << 8) + data [1];
|
|
|
|
#if 0
|
|
|
|
if ((looking_for & SIZE) == L_16)
|
2005-07-01 19:16:33 +08:00
|
|
|
*cst = (short) *cst; /* Sign extend. */
|
2003-06-04 05:32:52 +08:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case L_32:
|
|
|
|
*len = 32;
|
2019-12-10 21:23:57 +08:00
|
|
|
*cst = (((unsigned) data[0] << 24) + (data[1] << 16)
|
|
|
|
+ (data[2] << 8) + data[3]);
|
2003-06-04 05:32:52 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*len = 0;
|
|
|
|
*cst = 0;
|
|
|
|
fprintf (stream, "DISP bad size\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *regnames[] =
|
|
|
|
{
|
|
|
|
"r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
|
|
|
|
"r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"
|
|
|
|
};
|
|
|
|
static const char *wregnames[] =
|
|
|
|
{
|
|
|
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
|
|
|
"e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7"
|
|
|
|
};
|
|
|
|
static const char *lregnames[] =
|
|
|
|
{
|
|
|
|
"er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7",
|
|
|
|
"er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7"
|
|
|
|
};
|
|
|
|
static const char *cregnames[] =
|
|
|
|
{
|
|
|
|
"ccr", "exr", "mach", "macl", "", "", "vbr", "sbr"
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2005-07-01 19:16:33 +08:00
|
|
|
print_one_arg (disassemble_info *info,
|
|
|
|
bfd_vma addr,
|
|
|
|
op_type x,
|
|
|
|
int cst,
|
|
|
|
int cstlen,
|
|
|
|
int rdisp_n,
|
|
|
|
int rn,
|
|
|
|
const char **pregnames,
|
|
|
|
int len)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2005-07-01 19:16:33 +08:00
|
|
|
void * stream = info->stream;
|
2003-06-04 05:32:52 +08:00
|
|
|
fprintf_ftype outfn = info->fprintf_func;
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
if ((x & SIZE) == L_3 || (x & SIZE) == L_3NZ)
|
|
|
|
outfn (stream, "#0x%x", (unsigned) cst);
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == IMM)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "#0x%x", (unsigned) cst);
|
|
|
|
else if ((x & MODE) == DBIT || (x & MODE) == KBIT)
|
|
|
|
outfn (stream, "#%d", (unsigned) cst);
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == CONST_2)
|
|
|
|
outfn (stream, "#2");
|
|
|
|
else if ((x & MODE) == CONST_4)
|
|
|
|
outfn (stream, "#4");
|
|
|
|
else if ((x & MODE) == CONST_8)
|
|
|
|
outfn (stream, "#8");
|
|
|
|
else if ((x & MODE) == CONST_16)
|
|
|
|
outfn (stream, "#16");
|
|
|
|
else if ((x & MODE) == REG)
|
|
|
|
{
|
|
|
|
switch (x & SIZE)
|
|
|
|
{
|
|
|
|
case L_8:
|
|
|
|
outfn (stream, "%s", regnames[rn]);
|
|
|
|
break;
|
|
|
|
case L_16:
|
|
|
|
case L_16U:
|
|
|
|
outfn (stream, "%s", wregnames[rn]);
|
|
|
|
break;
|
|
|
|
case L_P:
|
|
|
|
case L_32:
|
|
|
|
outfn (stream, "%s", lregnames[rn]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((x & MODE) == LOWREG)
|
|
|
|
{
|
|
|
|
switch (x & SIZE)
|
|
|
|
{
|
|
|
|
case L_8:
|
|
|
|
/* Always take low half of reg. */
|
|
|
|
outfn (stream, "%s.b", regnames[rn < 8 ? rn + 8 : rn]);
|
|
|
|
break;
|
|
|
|
case L_16:
|
|
|
|
case L_16U:
|
|
|
|
/* Always take low half of reg. */
|
|
|
|
outfn (stream, "%s.w", wregnames[rn < 8 ? rn : rn - 8]);
|
|
|
|
break;
|
|
|
|
case L_P:
|
|
|
|
case L_32:
|
|
|
|
outfn (stream, "%s.l", lregnames[rn]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((x & MODE) == POSTINC)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@%s+", pregnames[rn]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == POSTDEC)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@%s-", pregnames[rn]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == PREINC)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@+%s", pregnames[rn]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == PREDEC)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@-%s", pregnames[rn]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == IND)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@%s", pregnames[rn]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == ABS || (x & ABSJMP))
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@0x%x:%d", (unsigned) cst, cstlen);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == MEMIND)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@@%d (0x%x)", cst, cst);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == VECIND)
|
|
|
|
{
|
|
|
|
/* FIXME Multiplier should be 2 or 4, depending on processor mode,
|
|
|
|
by which is meant "normal" vs. "middle", "advanced", "maximum". */
|
|
|
|
|
|
|
|
int offset = (cst + 0x80) * 4;
|
|
|
|
outfn (stream, "@@%d (0x%x)", offset, offset);
|
|
|
|
}
|
|
|
|
else if ((x & MODE) == PCREL)
|
|
|
|
{
|
|
|
|
if ((x & SIZE) == L_16 ||
|
|
|
|
(x & SIZE) == L_16U)
|
|
|
|
{
|
Kaveh Ghazi's printf format attribute checking patch.
bfd:
* elf32-xtensa.c (vsprint_msg): Add format attribute. Fix
format bugs.
* vms.h (_bfd_vms_debug): Add format attribute.
(_bfd_vms_debug, _bfd_hexdump): Fix typos.
binutils:
* bucomm.h (report): Add format attribute.
* dlltool.c (inform): Likewise.
* dllwrap.c (display, inform, warn): Likewise.
* objdump.c (objdump_sprintf): Likewise.
* readelf.c (error, warn): Likewise. Fix format bugs.
gas:
* config/tc-tic30.c (debug): Add format attribute. Fix format
bugs.
include:
* dis-asm.h (fprintf_ftype): Add format attribute.
opcodes:
* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
v850-dis.c: Fix format bugs.
* ia64-gen.c (fail, warn): Add format attribute.
* or32-opc.c (debug): Likewise.
2005-07-08 03:27:52 +08:00
|
|
|
outfn (stream, ".%s%d (0x%lx)",
|
2003-06-04 05:32:52 +08:00
|
|
|
(short) cst > 0 ? "+" : "",
|
2015-08-12 19:45:07 +08:00
|
|
|
(short) cst,
|
Kaveh Ghazi's printf format attribute checking patch.
bfd:
* elf32-xtensa.c (vsprint_msg): Add format attribute. Fix
format bugs.
* vms.h (_bfd_vms_debug): Add format attribute.
(_bfd_vms_debug, _bfd_hexdump): Fix typos.
binutils:
* bucomm.h (report): Add format attribute.
* dlltool.c (inform): Likewise.
* dllwrap.c (display, inform, warn): Likewise.
* objdump.c (objdump_sprintf): Likewise.
* readelf.c (error, warn): Likewise. Fix format bugs.
gas:
* config/tc-tic30.c (debug): Add format attribute. Fix format
bugs.
include:
* dis-asm.h (fprintf_ftype): Add format attribute.
opcodes:
* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
v850-dis.c: Fix format bugs.
* ia64-gen.c (fail, warn): Add format attribute.
* or32-opc.c (debug): Likewise.
2005-07-08 03:27:52 +08:00
|
|
|
(long)(addr + (short) cst + len));
|
2003-06-04 05:32:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Kaveh Ghazi's printf format attribute checking patch.
bfd:
* elf32-xtensa.c (vsprint_msg): Add format attribute. Fix
format bugs.
* vms.h (_bfd_vms_debug): Add format attribute.
(_bfd_vms_debug, _bfd_hexdump): Fix typos.
binutils:
* bucomm.h (report): Add format attribute.
* dlltool.c (inform): Likewise.
* dllwrap.c (display, inform, warn): Likewise.
* objdump.c (objdump_sprintf): Likewise.
* readelf.c (error, warn): Likewise. Fix format bugs.
gas:
* config/tc-tic30.c (debug): Add format attribute. Fix format
bugs.
include:
* dis-asm.h (fprintf_ftype): Add format attribute.
opcodes:
* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
v850-dis.c: Fix format bugs.
* ia64-gen.c (fail, warn): Add format attribute.
* or32-opc.c (debug): Likewise.
2005-07-08 03:27:52 +08:00
|
|
|
outfn (stream, ".%s%d (0x%lx)",
|
2003-06-04 05:32:52 +08:00
|
|
|
(char) cst > 0 ? "+" : "",
|
2015-08-12 19:45:07 +08:00
|
|
|
(char) cst,
|
Kaveh Ghazi's printf format attribute checking patch.
bfd:
* elf32-xtensa.c (vsprint_msg): Add format attribute. Fix
format bugs.
* vms.h (_bfd_vms_debug): Add format attribute.
(_bfd_vms_debug, _bfd_hexdump): Fix typos.
binutils:
* bucomm.h (report): Add format attribute.
* dlltool.c (inform): Likewise.
* dllwrap.c (display, inform, warn): Likewise.
* objdump.c (objdump_sprintf): Likewise.
* readelf.c (error, warn): Likewise. Fix format bugs.
gas:
* config/tc-tic30.c (debug): Add format attribute. Fix format
bugs.
include:
* dis-asm.h (fprintf_ftype): Add format attribute.
opcodes:
* arc-dis.c, arm-dis.c, cris-dis.c, crx-dis.c, d10v-dis.c,
d30v-dis.c, fr30-dis.c, h8300-dis.c, h8500-dis.c, i860-dis.c,
ia64-dis.c, ip2k-dis.c, m10200-dis.c, m10300-dis.c,
m88k-dis.c, mcore-dis.c, mips-dis.c, ms1-dis.c, or32-dis.c,
ppc-dis.c, sh64-dis.c, sparc-dis.c, tic4x-dis.c, tic80-dis.c,
v850-dis.c: Fix format bugs.
* ia64-gen.c (fail, warn): Add format attribute.
* or32-opc.c (debug): Likewise.
2005-07-08 03:27:52 +08:00
|
|
|
(long)(addr + (char) cst + len));
|
2003-06-04 05:32:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((x & MODE) == DISP)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@(0x%x:%d,%s)", cst, cstlen, pregnames[rdisp_n]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == INDEXB)
|
2005-07-01 19:16:33 +08:00
|
|
|
/* Always take low half of reg. */
|
2015-08-12 19:45:07 +08:00
|
|
|
outfn (stream, "@(0x%x:%d,%s.b)", cst, cstlen,
|
2005-07-01 19:16:33 +08:00
|
|
|
regnames[rdisp_n < 8 ? rdisp_n + 8 : rdisp_n]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == INDEXW)
|
2005-07-01 19:16:33 +08:00
|
|
|
/* Always take low half of reg. */
|
2015-08-12 19:45:07 +08:00
|
|
|
outfn (stream, "@(0x%x:%d,%s.w)", cst, cstlen,
|
2005-07-01 19:16:33 +08:00
|
|
|
wregnames[rdisp_n < 8 ? rdisp_n : rdisp_n - 8]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == INDEXL)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "@(0x%x:%d,%s.l)", cst, cstlen, lregnames[rdisp_n]);
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if (x & CTRL)
|
2012-08-01 08:41:35 +08:00
|
|
|
outfn (stream, "%s", cregnames[rn]);
|
2005-07-01 19:16:33 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == CCR)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "ccr");
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == EXR)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "exr");
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((x & MODE) == MACREG)
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "mac%c", cst ? 'l' : 'h');
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
else
|
|
|
|
/* xgettext:c-format */
|
|
|
|
outfn (stream, _("Hmmmm 0x%x"), x);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
2005-07-01 19:16:33 +08:00
|
|
|
bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
|
|
|
/* Find the first entry in the table for this opcode. */
|
|
|
|
int regno[3] = { 0, 0, 0 };
|
|
|
|
int dispregno[3] = { 0, 0, 0 };
|
|
|
|
int cst[3] = { 0, 0, 0 };
|
|
|
|
int cstlen[3] = { 0, 0, 0 };
|
2002-11-30 16:39:46 +08:00
|
|
|
static bfd_boolean init = 0;
|
2002-11-19 00:52:46 +08:00
|
|
|
const struct h8_instruction *qi;
|
2003-06-04 05:32:52 +08:00
|
|
|
char const **pregnames = mach != 0 ? lregnames : wregnames;
|
1999-05-03 15:29:11 +08:00
|
|
|
int status;
|
2003-06-04 05:32:52 +08:00
|
|
|
unsigned int l;
|
|
|
|
unsigned char data[MAX_CODE_NIBBLES];
|
1999-05-03 15:29:11 +08:00
|
|
|
void *stream = info->stream;
|
2003-06-04 05:32:52 +08:00
|
|
|
fprintf_ftype outfn = info->fprintf_func;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (!init)
|
|
|
|
{
|
|
|
|
bfd_h8_disassemble_init ();
|
|
|
|
init = 1;
|
|
|
|
}
|
|
|
|
|
2000-06-02 02:19:59 +08:00
|
|
|
status = info->read_memory_func (addr, data, 2, info);
|
2000-06-03 02:09:28 +08:00
|
|
|
if (status != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-02 02:19:59 +08:00
|
|
|
info->memory_error_func (status, addr, info);
|
1999-05-03 15:29:11 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
for (l = 2; status == 0 && l < sizeof (data) / 2; l += 2)
|
2000-06-13 06:23:25 +08:00
|
|
|
status = info->read_memory_func (addr + l, data + l, 2, info);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2000-06-02 02:19:59 +08:00
|
|
|
/* Find the exact opcode/arg combo. */
|
2002-11-19 00:52:46 +08:00
|
|
|
for (qi = h8_instructions; qi->opcode->name; qi++)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2002-11-19 00:52:46 +08:00
|
|
|
const struct h8_opcode *q = qi->opcode;
|
2006-10-26 23:37:21 +08:00
|
|
|
const op_type *nib = q->data.nib;
|
1999-05-03 15:29:11 +08:00
|
|
|
unsigned int len = 0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
op_type looking_for = *nib;
|
2003-06-04 05:32:52 +08:00
|
|
|
int thisnib = data[len / 2];
|
|
|
|
int opnr;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
thisnib = (len & 1) ? (thisnib & 0xf) : ((thisnib / 16) & 0xf);
|
|
|
|
opnr = ((looking_for & OP3) == OP3 ? 2
|
|
|
|
: (looking_for & DST) == DST ? 1 : 0);
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2000-06-03 02:09:28 +08:00
|
|
|
if (looking_for < 16 && looking_for >= 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-03 02:09:28 +08:00
|
|
|
if (looking_for != thisnib)
|
1999-05-03 15:29:11 +08:00
|
|
|
goto fail;
|
|
|
|
}
|
2000-06-03 02:09:28 +08:00
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if ((int) looking_for & (int) B31)
|
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
if (!((thisnib & 0x8) != 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
goto fail;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B31);
|
2003-06-04 05:32:52 +08:00
|
|
|
thisnib &= 0x7;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((int) looking_for & (int) B30)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
if (!((thisnib & 0x8) == 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
goto fail;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B30);
|
|
|
|
}
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
if ((int) looking_for & (int) B21)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x4) != 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B21);
|
|
|
|
thisnib &= 0xb;
|
|
|
|
}
|
|
|
|
else if ((int) looking_for & (int) B20)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x4) == 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B20);
|
|
|
|
}
|
|
|
|
if ((int) looking_for & (int) B11)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x2) != 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B11);
|
|
|
|
thisnib &= 0xd;
|
|
|
|
}
|
|
|
|
else if ((int) looking_for & (int) B10)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x2) == 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B10);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((int) looking_for & (int) B01)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x1) != 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B01);
|
|
|
|
thisnib &= 0xe;
|
|
|
|
}
|
|
|
|
else if ((int) looking_for & (int) B00)
|
|
|
|
{
|
|
|
|
if (!((thisnib & 0x1) == 0))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
looking_for = (op_type) ((int) looking_for & ~(int) B00);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (looking_for & IGNORE)
|
|
|
|
{
|
|
|
|
/* Hitachi has declared that IGNORE must be zero. */
|
|
|
|
if (thisnib != 0)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
else if ((looking_for & MODE) == DATA)
|
|
|
|
{
|
|
|
|
; /* Skip embedded data. */
|
|
|
|
}
|
|
|
|
else if ((looking_for & MODE) == DBIT)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-13 06:23:25 +08:00
|
|
|
/* Exclude adds/subs by looking at bit 0 and 2, and
|
|
|
|
make sure the operand size, either w or l,
|
|
|
|
matches by looking at bit 1. */
|
|
|
|
if ((looking_for & 7) != (thisnib & 7))
|
2000-06-02 02:19:59 +08:00
|
|
|
goto fail;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = (thisnib & 0x8) ? 2 : 1;
|
2000-06-03 02:09:28 +08:00
|
|
|
}
|
2005-07-01 19:16:33 +08:00
|
|
|
else if ((looking_for & MODE) == DISP
|
|
|
|
|| (looking_for & MODE) == ABS
|
|
|
|
|| (looking_for & MODE) == PCREL
|
|
|
|
|| (looking_for & MODE) == INDEXB
|
|
|
|
|| (looking_for & MODE) == INDEXW
|
|
|
|
|| (looking_for & MODE) == INDEXL)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2015-08-12 19:45:07 +08:00
|
|
|
extract_immediate (stream, looking_for, thisnib,
|
|
|
|
data + len / 2, cst + opnr,
|
2003-06-04 05:32:52 +08:00
|
|
|
cstlen + opnr, q);
|
|
|
|
/* Even address == bra, odd == bra/s. */
|
|
|
|
if (q->how == O (O_BRAS, SB))
|
|
|
|
cst[opnr] -= 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2005-07-01 19:16:33 +08:00
|
|
|
else if ((looking_for & MODE) == REG
|
|
|
|
|| (looking_for & MODE) == LOWREG
|
|
|
|
|| (looking_for & MODE) == IND
|
|
|
|
|| (looking_for & MODE) == PREINC
|
|
|
|
|| (looking_for & MODE) == POSTINC
|
|
|
|
|| (looking_for & MODE) == PREDEC
|
|
|
|
|| (looking_for & MODE) == POSTDEC)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
regno[opnr] = thisnib;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2005-07-01 19:16:33 +08:00
|
|
|
else if (looking_for & CTRL) /* Control Register. */
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
thisnib &= 7;
|
2005-07-01 19:16:33 +08:00
|
|
|
if (((looking_for & MODE) == CCR && (thisnib != C_CCR))
|
|
|
|
|| ((looking_for & MODE) == EXR && (thisnib != C_EXR))
|
|
|
|
|| ((looking_for & MODE) == MACH && (thisnib != C_MACH))
|
|
|
|
|| ((looking_for & MODE) == MACL && (thisnib != C_MACL))
|
|
|
|
|| ((looking_for & MODE) == VBR && (thisnib != C_VBR))
|
|
|
|
|| ((looking_for & MODE) == SBR && (thisnib != C_SBR)))
|
2003-06-04 05:32:52 +08:00
|
|
|
goto fail;
|
2005-07-01 19:16:33 +08:00
|
|
|
if (((looking_for & MODE) == CCR_EXR
|
|
|
|
&& (thisnib != C_CCR && thisnib != C_EXR))
|
|
|
|
|| ((looking_for & MODE) == VBR_SBR
|
|
|
|
&& (thisnib != C_VBR && thisnib != C_SBR))
|
|
|
|
|| ((looking_for & MODE) == MACREG
|
|
|
|
&& (thisnib != C_MACH && thisnib != C_MACL)))
|
2003-06-04 05:32:52 +08:00
|
|
|
goto fail;
|
2005-07-01 19:16:33 +08:00
|
|
|
if (((looking_for & MODE) == CC_EX_VB_SB
|
|
|
|
&& (thisnib != C_CCR && thisnib != C_EXR
|
|
|
|
&& thisnib != C_VBR && thisnib != C_SBR)))
|
2003-06-04 05:32:52 +08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
regno[opnr] = thisnib;
|
|
|
|
}
|
|
|
|
else if ((looking_for & SIZE) == L_5)
|
|
|
|
{
|
|
|
|
cst[opnr] = data[len / 2] & 31;
|
|
|
|
cstlen[opnr] = 5;
|
|
|
|
}
|
|
|
|
else if ((looking_for & SIZE) == L_4)
|
|
|
|
{
|
|
|
|
cst[opnr] = thisnib;
|
|
|
|
cstlen[opnr] = 4;
|
|
|
|
}
|
2005-07-01 19:16:33 +08:00
|
|
|
else if ((looking_for & SIZE) == L_16
|
|
|
|
|| (looking_for & SIZE) == L_16U)
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
|
|
|
cst[opnr] = (data[len / 2]) * 256 + data[(len + 2) / 2];
|
|
|
|
cstlen[opnr] = 16;
|
|
|
|
}
|
|
|
|
else if ((looking_for & MODE) == MEMIND)
|
|
|
|
{
|
|
|
|
cst[opnr] = data[1];
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & MODE) == VECIND)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = data[1] & 0x7f;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & SIZE) == L_32)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
int i = len / 2;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2019-12-10 21:23:57 +08:00
|
|
|
cst[opnr] = (((unsigned) data[i] << 24)
|
2015-08-12 19:45:07 +08:00
|
|
|
| (data[i + 1] << 16)
|
2003-06-04 05:32:52 +08:00
|
|
|
| (data[i + 2] << 8)
|
|
|
|
| (data[i + 3]));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
cstlen[opnr] = 32;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & SIZE) == L_24)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
int i = len / 2;
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2015-08-12 19:45:07 +08:00
|
|
|
cst[opnr] =
|
2003-06-04 05:32:52 +08:00
|
|
|
(data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);
|
|
|
|
cstlen[opnr] = 24;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else if (looking_for & DISPREG)
|
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
dispregno[opnr] = thisnib & 7;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & MODE) == KBIT)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-03 02:09:28 +08:00
|
|
|
switch (thisnib)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
case 9:
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = 4;
|
1999-05-03 15:29:11 +08:00
|
|
|
break;
|
|
|
|
case 8:
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
break;
|
|
|
|
case 0:
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & SIZE) == L_8)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
cstlen[opnr] = 8;
|
|
|
|
cst[opnr] = data[len / 2];
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2005-07-01 19:16:33 +08:00
|
|
|
else if ((looking_for & SIZE) == L_3
|
|
|
|
|| (looking_for & SIZE) == L_3NZ)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = thisnib & 0x7;
|
|
|
|
if (cst[opnr] == 0 && (looking_for & SIZE) == L_3NZ)
|
|
|
|
goto fail;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & SIZE) == L_2)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
cstlen[opnr] = 2;
|
|
|
|
cst[opnr] = thisnib & 0x3;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if ((looking_for & MODE) == MACREG)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
cst[opnr] = (thisnib == 3);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2003-06-04 05:32:52 +08:00
|
|
|
else if (looking_for == (op_type) E)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
outfn (stream, "%s\t", q->name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* Gross. Disgusting. */
|
|
|
|
if (strcmp (q->name, "ldm.l") == 0)
|
|
|
|
{
|
|
|
|
int count, high;
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
count = (data[1] / 16) & 0x3;
|
|
|
|
high = regno[1];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
outfn (stream, "@sp+,er%d-er%d", high - count, high);
|
2002-11-19 00:52:46 +08:00
|
|
|
return qi->length;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (q->name, "stm.l") == 0)
|
|
|
|
{
|
|
|
|
int count, low;
|
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
count = (data[1] / 16) & 0x3;
|
|
|
|
low = regno[0];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2003-06-04 05:32:52 +08:00
|
|
|
outfn (stream, "er%d-er%d,@-sp", low, low + count);
|
|
|
|
return qi->length;
|
|
|
|
}
|
|
|
|
if (strcmp (q->name, "rte/l") == 0
|
|
|
|
|| strcmp (q->name, "rts/l") == 0)
|
|
|
|
{
|
|
|
|
if (regno[0] == 0)
|
|
|
|
outfn (stream, "er%d", regno[1]);
|
|
|
|
else
|
2005-07-01 19:16:33 +08:00
|
|
|
outfn (stream, "er%d-er%d", regno[1] - regno[0],
|
|
|
|
regno[1]);
|
2003-06-04 05:32:52 +08:00
|
|
|
return qi->length;
|
|
|
|
}
|
2006-09-17 02:12:17 +08:00
|
|
|
if (CONST_STRNEQ (q->name, "mova"))
|
2003-06-04 05:32:52 +08:00
|
|
|
{
|
2006-10-26 23:37:21 +08:00
|
|
|
const op_type *args = q->args.nib;
|
2003-06-04 05:32:52 +08:00
|
|
|
|
|
|
|
if (args[1] == (op_type) E)
|
|
|
|
{
|
|
|
|
/* Short form. */
|
2015-08-12 19:45:07 +08:00
|
|
|
print_one_arg (info, addr, args[0], cst[0],
|
|
|
|
cstlen[0], dispregno[0], regno[0],
|
2003-06-04 05:32:52 +08:00
|
|
|
pregnames, qi->length);
|
|
|
|
outfn (stream, ",er%d", dispregno[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outfn (stream, "@(0x%x:%d,", cst[0], cstlen[0]);
|
2015-08-12 19:45:07 +08:00
|
|
|
print_one_arg (info, addr, args[1], cst[1],
|
|
|
|
cstlen[1], dispregno[1], regno[1],
|
2003-06-04 05:32:52 +08:00
|
|
|
pregnames, qi->length);
|
|
|
|
outfn (stream, ".%c),",
|
|
|
|
(args[0] & MODE) == INDEXB ? 'b' : 'w');
|
2015-08-12 19:45:07 +08:00
|
|
|
print_one_arg (info, addr, args[2], cst[2],
|
|
|
|
cstlen[2], dispregno[2], regno[2],
|
2003-06-04 05:32:52 +08:00
|
|
|
pregnames, qi->length);
|
|
|
|
}
|
2002-11-19 00:52:46 +08:00
|
|
|
return qi->length;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2000-06-02 02:19:59 +08:00
|
|
|
/* Fill in the args. */
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2006-10-26 23:37:21 +08:00
|
|
|
const op_type *args = q->args.nib;
|
1999-05-03 15:29:11 +08:00
|
|
|
int hadone = 0;
|
2003-06-04 05:32:52 +08:00
|
|
|
int nargs;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2004-04-15 16:55:27 +08:00
|
|
|
/* Special case handling for the adds and subs instructions
|
2005-07-01 19:16:33 +08:00
|
|
|
since in H8 mode thay can only take the r0-r7 registers
|
|
|
|
but in other (higher) modes they can take the er0-er7
|
|
|
|
registers as well. */
|
2004-04-15 16:55:27 +08:00
|
|
|
if (strcmp (qi->opcode->name, "adds") == 0
|
|
|
|
|| strcmp (qi->opcode->name, "subs") == 0)
|
|
|
|
{
|
|
|
|
outfn (stream, "#%d,%s", cst[0], pregnames[regno[1] & 0x7]);
|
|
|
|
return qi->length;
|
|
|
|
}
|
|
|
|
|
2015-08-12 19:45:07 +08:00
|
|
|
for (nargs = 0;
|
2005-07-01 19:16:33 +08:00
|
|
|
nargs < 3 && args[nargs] != (op_type) E;
|
2003-06-04 05:32:52 +08:00
|
|
|
nargs++)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-06-04 05:32:52 +08:00
|
|
|
int x = args[nargs];
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (hadone)
|
2003-06-04 05:32:52 +08:00
|
|
|
outfn (stream, ",");
|
|
|
|
|
|
|
|
print_one_arg (info, addr, x,
|
|
|
|
cst[nargs], cstlen[nargs],
|
|
|
|
dispregno[nargs], regno[nargs],
|
|
|
|
pregnames, qi->length);
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
hadone = 1;
|
|
|
|
}
|
|
|
|
}
|
2000-06-13 06:23:25 +08:00
|
|
|
|
2002-11-19 00:52:46 +08:00
|
|
|
return qi->length;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else
|
2000-06-03 02:09:28 +08:00
|
|
|
/* xgettext:c-format */
|
2003-06-04 05:32:52 +08:00
|
|
|
outfn (stream, _("Don't understand 0x%x \n"), looking_for);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
len++;
|
|
|
|
nib++;
|
|
|
|
}
|
2000-06-13 06:23:25 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
fail:
|
2000-07-04 05:52:37 +08:00
|
|
|
;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2000-06-03 02:09:28 +08:00
|
|
|
/* Fell off the end. */
|
2004-07-23 00:52:43 +08:00
|
|
|
outfn (stream, ".word\tH'%x,H'%x", data[0], data[1]);
|
1999-05-03 15:29:11 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2000-06-03 02:09:28 +08:00
|
|
|
int
|
2005-07-01 19:16:33 +08:00
|
|
|
print_insn_h8300 (bfd_vma addr, disassemble_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-03 02:09:28 +08:00
|
|
|
return bfd_h8_disassemble (addr, info, 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2000-06-03 02:09:28 +08:00
|
|
|
int
|
2005-07-01 19:16:33 +08:00
|
|
|
print_insn_h8300h (bfd_vma addr, disassemble_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-03 02:09:28 +08:00
|
|
|
return bfd_h8_disassemble (addr, info, 1);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2000-06-03 02:09:28 +08:00
|
|
|
int
|
2005-07-01 19:16:33 +08:00
|
|
|
print_insn_h8300s (bfd_vma addr, disassemble_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-03 02:09:28 +08:00
|
|
|
return bfd_h8_disassemble (addr, info, 2);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|