1996-12-28 06:36:52 +01:00
|
|
|
|
/* Print TI TMS320C80 (MVP) instructions
|
1997-01-19 19:33:10 +01:00
|
|
|
|
Copyright 1996, 1997 Free Software Foundation, Inc.
|
1996-12-28 06:36:52 +01:00
|
|
|
|
|
|
|
|
|
This file 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.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1996-12-29 19:01:29 +01:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "ansidecl.h"
|
|
|
|
|
#include "opcode/tic80.h"
|
|
|
|
|
#include "dis-asm.h"
|
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
static int length;
|
* tic80-dis.c (M_SI, M_LI): Add macros to test for ":m" modifier bit
in an instruction.
* tic80-dis.c (print_insn_tic80): Change comma and paren handling.
Use M_SI and M_LI macros to check for ":m" modifier for GPR operands.
* tic80-opc.c (tic80_operands): Add REGM_SI and REGM_LI operands.
(F, M_REG, M_LI, M_SI, SZ_REG, SZ_LI, SZ_SI, D, S): New bit-twiddlers.
(MASK_LI_M, MASK_SI_M, MASK_REG_M): Remove and replace in opcode
masks with "MASK_* & ~M_*" to get the M bit reset.
(tic80_opcodes): Add bsr, bsr.a, cmnd, cmp, dcachec, and dcachef.
1997-01-05 20:29:42 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
static void print_operand_bitnum PARAMS ((struct disassemble_info *, long));
|
|
|
|
|
static void print_operand_condition_code PARAMS ((struct disassemble_info *, long));
|
|
|
|
|
static void print_operand_control_register PARAMS ((struct disassemble_info *, long));
|
|
|
|
|
static void print_operand_float PARAMS ((struct disassemble_info *, long));
|
|
|
|
|
static void print_operand_integer PARAMS ((struct disassemble_info *, long));
|
|
|
|
|
static void print_operand PARAMS ((struct disassemble_info *, long, unsigned long,
|
|
|
|
|
const struct tic80_operand *, bfd_vma));
|
|
|
|
|
static int print_one_instruction PARAMS ((struct disassemble_info *, bfd_vma,
|
|
|
|
|
unsigned long, const struct tic80_opcode *));
|
|
|
|
|
static int print_instruction PARAMS ((struct disassemble_info *, bfd_vma, unsigned long,
|
|
|
|
|
const struct tic80_opcode *));
|
|
|
|
|
static int fill_instruction PARAMS ((struct disassemble_info *, bfd_vma,
|
|
|
|
|
unsigned long *));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Print an integer operand. Try to be somewhat smart about the
|
|
|
|
|
format by assuming that small positive or negative integers are
|
|
|
|
|
probably loop increment values, structure offsets, or similar
|
|
|
|
|
values that are more meaningful printed as signed decimal values.
|
|
|
|
|
Larger numbers are probably better printed as hex values. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand_integer (info, value)
|
1996-12-29 19:01:29 +01:00
|
|
|
|
struct disassemble_info *info;
|
1997-01-19 19:33:10 +01:00
|
|
|
|
long value;
|
1996-12-29 19:01:29 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
if ((value > 9999 || value < -9999))
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%#lx", value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%ld", value);
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
|
|
|
|
/* FIXME: depends upon sizeof (long) == sizeof (float) and
|
|
|
|
|
also upon host floating point format matching target
|
|
|
|
|
floating point format. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand_float (info, value)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
long value;
|
|
|
|
|
{
|
|
|
|
|
union { float f; long l; } fval;
|
|
|
|
|
|
|
|
|
|
fval.l = value;
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%g", fval.f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand_control_register (info, value)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
long value;
|
|
|
|
|
{
|
1997-01-30 22:16:46 +01:00
|
|
|
|
const char *tmp;
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
1997-01-30 22:16:46 +01:00
|
|
|
|
tmp = tic80_value_to_symbol (value, TIC80_OPERAND_CR);
|
1997-01-19 19:33:10 +01:00
|
|
|
|
if (tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%s", tmp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%#lx", value);
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand_condition_code (info, value)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
long value;
|
|
|
|
|
{
|
1997-01-30 22:16:46 +01:00
|
|
|
|
const char *tmp;
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
1997-01-30 22:16:46 +01:00
|
|
|
|
tmp = tic80_value_to_symbol (value, TIC80_OPERAND_CC);
|
|
|
|
|
if (tmp != NULL)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-30 22:16:46 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%s", tmp);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%ld", value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand_bitnum (info, value)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
long value;
|
|
|
|
|
{
|
|
|
|
|
int bitnum;
|
1997-01-30 22:16:46 +01:00
|
|
|
|
const char *tmp;
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
|
|
|
|
bitnum = ~value & 0x1F;
|
1997-01-30 22:16:46 +01:00
|
|
|
|
tmp = tic80_value_to_symbol (bitnum, TIC80_OPERAND_BITNUM);
|
|
|
|
|
if (tmp != NULL)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-30 22:16:46 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%s", tmp);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%ld", bitnum);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
|
|
|
|
/* Print the operand as directed by the flags. */
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
#define M_SI(insn,op) ((((op) -> flags & TIC80_OPERAND_M_SI) != 0) && ((insn) & (1 << 17)))
|
|
|
|
|
#define M_LI(insn,op) ((((op) -> flags & TIC80_OPERAND_M_LI) != 0) && ((insn) & (1 << 15)))
|
|
|
|
|
#define R_SCALED(insn,op) ((((op) -> flags & TIC80_OPERAND_SCALED) != 0) && ((insn) & (1 << 11)))
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_operand (info, value, insn, operand, memaddr)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
long value;
|
|
|
|
|
unsigned long insn;
|
|
|
|
|
const struct tic80_operand *operand;
|
|
|
|
|
bfd_vma memaddr;
|
|
|
|
|
{
|
|
|
|
|
if ((operand -> flags & TIC80_OPERAND_GPR) != 0)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, "r%ld", value);
|
|
|
|
|
if (M_SI (insn, operand) || M_LI (insn, operand))
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, ":m");
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_FPA) != 0)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, "a%ld", value);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_PCREL) != 0)
|
|
|
|
|
{
|
|
|
|
|
(*info -> print_address_func) (memaddr + 4 * value, info);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_BASEREL) != 0)
|
|
|
|
|
{
|
|
|
|
|
(*info -> print_address_func) (value, info);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_BITNUM) != 0)
|
|
|
|
|
{
|
|
|
|
|
print_operand_bitnum (info, value);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_CC) != 0)
|
|
|
|
|
{
|
|
|
|
|
print_operand_condition_code (info, value);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_CR) != 0)
|
|
|
|
|
{
|
|
|
|
|
print_operand_control_register (info, value);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_FLOAT) != 0)
|
|
|
|
|
{
|
|
|
|
|
print_operand_float (info, value);
|
|
|
|
|
}
|
|
|
|
|
else if ((operand -> flags & TIC80_OPERAND_BITFIELD))
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%#lx", value);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
print_operand_integer (info, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a scaled operand, then print the modifier */
|
|
|
|
|
|
|
|
|
|
if (R_SCALED (insn, operand))
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, ":s");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We have chosen an opcode table entry */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
print_one_instruction (info, memaddr, insn, opcode)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
bfd_vma memaddr;
|
|
|
|
|
unsigned long insn;
|
|
|
|
|
const struct tic80_opcode *opcode;
|
|
|
|
|
{
|
|
|
|
|
const struct tic80_operand *operand;
|
|
|
|
|
long value;
|
|
|
|
|
int status;
|
|
|
|
|
const unsigned char *opindex;
|
|
|
|
|
bfd_byte buffer[4];
|
|
|
|
|
int close_paren;
|
|
|
|
|
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "%-10s", opcode -> name);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
for (opindex = opcode -> operands; *opindex != 0; opindex++)
|
|
|
|
|
{
|
|
|
|
|
operand = tic80_operands + *opindex;
|
|
|
|
|
|
|
|
|
|
/* Extract the value from the instruction. */
|
|
|
|
|
if (operand -> extract)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
value = (*operand -> extract) (insn, (int *) NULL);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
else if (operand -> bits == 32)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
status = fill_instruction (info, memaddr, (unsigned long *) &value);
|
|
|
|
|
if (status == -1)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
return (status);
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = (insn >> operand -> shift) & ((1 << operand -> bits) - 1);
|
|
|
|
|
if ((operand -> flags & TIC80_OPERAND_SIGNED) != 0
|
|
|
|
|
&& (value & (1 << (operand -> bits - 1))) != 0)
|
1997-01-04 02:39:30 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
value -= 1 << operand -> bits;
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
/* If this operand is enclosed in parenthesis, then print
|
|
|
|
|
the open paren, otherwise just print the regular comma
|
|
|
|
|
separator, except for the first operand. */
|
* tic80-dis.c (M_SI, M_LI): Add macros to test for ":m" modifier bit
in an instruction.
* tic80-dis.c (print_insn_tic80): Change comma and paren handling.
Use M_SI and M_LI macros to check for ":m" modifier for GPR operands.
* tic80-opc.c (tic80_operands): Add REGM_SI and REGM_LI operands.
(F, M_REG, M_LI, M_SI, SZ_REG, SZ_LI, SZ_SI, D, S): New bit-twiddlers.
(MASK_LI_M, MASK_SI_M, MASK_REG_M): Remove and replace in opcode
masks with "MASK_* & ~M_*" to get the M bit reset.
(tic80_opcodes): Add bsr, bsr.a, cmnd, cmp, dcachec, and dcachef.
1997-01-05 20:29:42 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
if ((operand -> flags & TIC80_OPERAND_PARENS) == 0)
|
|
|
|
|
{
|
|
|
|
|
close_paren = 0;
|
|
|
|
|
if (opindex != opcode -> operands)
|
* tic80-dis.c (M_SI, M_LI): Add macros to test for ":m" modifier bit
in an instruction.
* tic80-dis.c (print_insn_tic80): Change comma and paren handling.
Use M_SI and M_LI macros to check for ":m" modifier for GPR operands.
* tic80-opc.c (tic80_operands): Add REGM_SI and REGM_LI operands.
(F, M_REG, M_LI, M_SI, SZ_REG, SZ_LI, SZ_SI, D, S): New bit-twiddlers.
(MASK_LI_M, MASK_SI_M, MASK_REG_M): Remove and replace in opcode
masks with "MASK_* & ~M_*" to get the M bit reset.
(tic80_opcodes): Add bsr, bsr.a, cmnd, cmp, dcachec, and dcachef.
1997-01-05 20:29:42 +01:00
|
|
|
|
{
|
1997-01-19 19:33:10 +01:00
|
|
|
|
(*info -> fprintf_func) (info -> stream, ",");
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
close_paren = 1;
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, "(");
|
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
print_operand (info, value, insn, operand, memaddr);
|
* tic80-dis.c (M_SI, M_LI): Add macros to test for ":m" modifier bit
in an instruction.
* tic80-dis.c (print_insn_tic80): Change comma and paren handling.
Use M_SI and M_LI macros to check for ":m" modifier for GPR operands.
* tic80-opc.c (tic80_operands): Add REGM_SI and REGM_LI operands.
(F, M_REG, M_LI, M_SI, SZ_REG, SZ_LI, SZ_SI, D, S): New bit-twiddlers.
(MASK_LI_M, MASK_SI_M, MASK_REG_M): Remove and replace in opcode
masks with "MASK_* & ~M_*" to get the M bit reset.
(tic80_opcodes): Add bsr, bsr.a, cmnd, cmp, dcachec, and dcachef.
1997-01-05 20:29:42 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
/* If we printed an open paren before printing this operand, close
|
|
|
|
|
it now. The flag gets reset on each loop. */
|
1997-01-14 00:05:49 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
if (close_paren)
|
|
|
|
|
{
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, ")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (length);
|
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
* tic80-dis.c (R_SCALED): Add macro to test for ":s" modifier bit.
(print_insn_tic80): If R_SCALED then print ":s" modifier for operand.
* tic80-opc.c (REG0, REG22, REG27, SSOFF, LSOFF): Names
changed to REG_0, REG_22, REG_DEST, OFF_SS, OFF_SL respectively.
(SICR, LICR, REGM_SI, REGM_LI): Names changed to CR_SI, CR_LI,
REG_BASE_M_SI, REG_BASE_M_LI respectively.
(REG_SCALED, LSI_SCALED): New operand types.
(E): New macro for 'E' bit at bit 27.
(tic80_opcodes): Add and test dld, dld.u, dst, estop, and etrap
opcodes, including the various size flavors (b,h,w,d) for
the direct load and store instructions.
1997-01-06 19:04:38 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
/* There are no specific bits that tell us for certain whether a vector
|
|
|
|
|
instruction opcode contains one or two instructions. However since
|
|
|
|
|
a destination register of r0 is illegal, we can check for nonzero
|
|
|
|
|
values in both destination register fields. Only opcodes that have
|
|
|
|
|
two valid instructions will have non-zero in both */
|
* tic80-dis.c (R_SCALED): Add macro to test for ":s" modifier bit.
(print_insn_tic80): If R_SCALED then print ":s" modifier for operand.
* tic80-opc.c (REG0, REG22, REG27, SSOFF, LSOFF): Names
changed to REG_0, REG_22, REG_DEST, OFF_SS, OFF_SL respectively.
(SICR, LICR, REGM_SI, REGM_LI): Names changed to CR_SI, CR_LI,
REG_BASE_M_SI, REG_BASE_M_LI respectively.
(REG_SCALED, LSI_SCALED): New operand types.
(E): New macro for 'E' bit at bit 27.
(tic80_opcodes): Add and test dld, dld.u, dst, estop, and etrap
opcodes, including the various size flavors (b,h,w,d) for
the direct load and store instructions.
1997-01-06 19:04:38 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
#define TWO_INSN(insn) ((((insn) & (0x1F << 27)) != 0) && (((insn) & (0x1F << 22)) != 0))
|
1997-01-04 02:39:30 +01:00
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
static int
|
|
|
|
|
print_instruction (info, memaddr, insn, vec_opcode)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
bfd_vma memaddr;
|
|
|
|
|
unsigned long insn;
|
|
|
|
|
const struct tic80_opcode *vec_opcode;
|
|
|
|
|
{
|
|
|
|
|
const struct tic80_opcode *opcode;
|
|
|
|
|
const struct tic80_opcode *opcode_end;
|
|
|
|
|
|
|
|
|
|
/* Find the first opcode match in the opcodes table. For vector
|
|
|
|
|
opcodes (vec_opcode != NULL) find the first match that is not the
|
|
|
|
|
previously found match. FIXME: there should be faster ways to
|
|
|
|
|
search (hash table or binary search), but don't worry too much
|
|
|
|
|
about it until other TIc80 support is finished. */
|
|
|
|
|
|
|
|
|
|
opcode_end = tic80_opcodes + tic80_num_opcodes;
|
|
|
|
|
for (opcode = tic80_opcodes; opcode < opcode_end; opcode++)
|
|
|
|
|
{
|
|
|
|
|
if ((insn & opcode -> mask) == opcode -> opcode &&
|
|
|
|
|
opcode != vec_opcode)
|
|
|
|
|
{
|
|
|
|
|
break;
|
1997-01-04 02:39:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-01-19 19:33:10 +01:00
|
|
|
|
if (opcode == opcode_end)
|
|
|
|
|
{
|
|
|
|
|
/* No match found, just print the bits as a .word directive */
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, ".word %#08lx", insn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Match found, decode the instruction. */
|
|
|
|
|
length = print_one_instruction (info, memaddr, insn, opcode);
|
|
|
|
|
if (opcode -> flags & TIC80_VECTOR && vec_opcode == NULL && TWO_INSN (insn))
|
|
|
|
|
{
|
|
|
|
|
/* There is another instruction to print from the same opcode.
|
|
|
|
|
Print the separator and then find and print the other
|
|
|
|
|
instruction. */
|
|
|
|
|
(*info -> fprintf_func) (info -> stream, " || ");
|
|
|
|
|
length = print_instruction (info, memaddr, insn, opcode);
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-01-04 02:39:30 +01:00
|
|
|
|
return (length);
|
1996-12-29 19:01:29 +01:00
|
|
|
|
}
|
1997-01-19 19:33:10 +01:00
|
|
|
|
|
|
|
|
|
/* Get the next 32 bit word from the instruction stream and convert it
|
|
|
|
|
into internal format in the unsigned long INSN, for which we are
|
|
|
|
|
passed the address. Return 0 on success, -1 on error. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
fill_instruction (info, memaddr, insnp)
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
bfd_vma memaddr;
|
|
|
|
|
unsigned long *insnp;
|
|
|
|
|
{
|
|
|
|
|
bfd_byte buffer[4];
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
/* Get the bits for the next 32 bit word and put in buffer */
|
|
|
|
|
|
|
|
|
|
status = (*info -> read_memory_func) (memaddr + length, buffer, 4, info);
|
|
|
|
|
if (status != 0)
|
|
|
|
|
{
|
|
|
|
|
(*info -> memory_error_func) (status, memaddr, info);
|
|
|
|
|
return (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read was successful, so increment count of bytes read and convert
|
|
|
|
|
the bits into internal format. */
|
|
|
|
|
|
|
|
|
|
length += 4;
|
|
|
|
|
if (info -> endian == BFD_ENDIAN_LITTLE)
|
|
|
|
|
{
|
|
|
|
|
*insnp = bfd_getl32 (buffer);
|
|
|
|
|
}
|
|
|
|
|
else if (info -> endian == BFD_ENDIAN_BIG)
|
|
|
|
|
{
|
|
|
|
|
*insnp = bfd_getb32 (buffer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Should probably just default to one or the other */
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
print_insn_tic80 (memaddr, info)
|
|
|
|
|
bfd_vma memaddr;
|
|
|
|
|
struct disassemble_info *info;
|
|
|
|
|
{
|
|
|
|
|
unsigned long insn;
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
length = 0;
|
|
|
|
|
status = fill_instruction (info, memaddr, &insn);
|
|
|
|
|
if (status != -1)
|
|
|
|
|
{
|
|
|
|
|
status = print_instruction (info, memaddr, insn, NULL);
|
|
|
|
|
}
|
|
|
|
|
return (status);
|
|
|
|
|
}
|