2002-12-30 20:25:13 +01:00
|
|
|
/* Disassemble MSP430 instructions.
|
2020-01-01 08:57:01 +01:00
|
|
|
Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
2013-05-02 23:06:15 +02:00
|
|
|
|
2002-12-30 20:25:13 +01:00
|
|
|
Contributed by Dmitry Diky <diwil@mail.ru>
|
2015-08-12 13:45:07 +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
|
2002-12-30 20:25:13 +01: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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2002-12-30 20:25:13 +01: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 13:16:33 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA. */
|
2002-12-30 20:25:13 +01:00
|
|
|
|
2012-05-18 03:59:38 +02:00
|
|
|
#include "sysdep.h"
|
2002-12-30 20:25:13 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
2016-05-27 14:49:58 +02:00
|
|
|
#include <errno.h>
|
2002-12-30 20:25:13 +01:00
|
|
|
|
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"
|
2002-12-30 20:25:13 +01:00
|
|
|
#include "opintl.h"
|
|
|
|
#include "libiberty.h"
|
|
|
|
|
|
|
|
#define DASM_SECTION
|
|
|
|
#include "opcode/msp430.h"
|
|
|
|
#undef DASM_SECTION
|
|
|
|
|
|
|
|
|
|
|
|
#define PS(x) (0xffff & (x))
|
|
|
|
|
2016-05-27 14:49:58 +02:00
|
|
|
static bfd_boolean
|
|
|
|
msp430dis_read_two_bytes (bfd_vma addr,
|
|
|
|
disassemble_info * info,
|
|
|
|
bfd_byte * buffer,
|
|
|
|
char * comm)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = info->read_memory_func (addr, buffer, 2, info);
|
2016-05-27 14:49:58 +02:00
|
|
|
if (status == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* PR 20150: A status of EIO means that there were no more bytes left
|
|
|
|
to read in the current section. This can happen when disassembling
|
|
|
|
interrupt vectors for example. Avoid cluttering the output with
|
|
|
|
unhelpful error messages in this case. */
|
|
|
|
if (status == EIO)
|
|
|
|
{
|
|
|
|
if (comm)
|
|
|
|
sprintf (comm, _("Warning: disassembly unreliable - not enough bytes available"));
|
|
|
|
}
|
|
|
|
else
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
info->memory_error_func (status, addr, info);
|
2016-05-27 14:49:58 +02:00
|
|
|
if (comm)
|
|
|
|
sprintf (comm, _("Error: read from memory failed"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
msp430dis_opcode_unsigned (bfd_vma addr,
|
|
|
|
disassemble_info * info,
|
|
|
|
unsigned short * return_val,
|
|
|
|
char * comm)
|
|
|
|
{
|
|
|
|
bfd_byte buffer[2];
|
|
|
|
|
|
|
|
if (msp430dis_read_two_bytes (addr, info, buffer, comm))
|
|
|
|
{
|
|
|
|
* return_val = bfd_getl16 (buffer);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
* return_val = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
msp430dis_opcode_signed (bfd_vma addr,
|
|
|
|
disassemble_info * info,
|
|
|
|
signed int * return_val,
|
|
|
|
char * comm)
|
|
|
|
{
|
|
|
|
bfd_byte buffer[2];
|
|
|
|
|
|
|
|
if (msp430dis_read_two_bytes (addr, info, buffer, comm))
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = bfd_getl_signed_16 (buffer);
|
|
|
|
if (status & 0x8000)
|
|
|
|
status |= -1U << 16;
|
|
|
|
* return_val = status;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
* return_val = 0;
|
|
|
|
return FALSE;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
static int
|
|
|
|
msp430_nooperands (struct msp430_opcode_s *opcode,
|
|
|
|
bfd_vma addr ATTRIBUTE_UNUSED,
|
|
|
|
unsigned short insn ATTRIBUTE_UNUSED,
|
|
|
|
char *comm,
|
|
|
|
int *cycles)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
/* Pop with constant. */
|
|
|
|
if (insn == 0x43b2)
|
|
|
|
return 0;
|
|
|
|
if (insn == opcode->bin_opcode)
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
if (opcode->fmt == 0)
|
|
|
|
{
|
2015-06-04 17:33:12 +02:00
|
|
|
if ((insn & 0x0f00) != 0x0300 || (insn & 0x0f00) != 0x0200)
|
2002-12-30 20:25:13 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
strcpy (comm, "emulated...");
|
|
|
|
*cycles = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy (comm, "return from interupt");
|
|
|
|
*cycles = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
static int
|
|
|
|
print_as2_reg_name (int regno, char * op1, char * comm1,
|
|
|
|
int c2, int c3, int cd)
|
|
|
|
{
|
|
|
|
switch (regno)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
sprintf (op1, "#4");
|
|
|
|
sprintf (comm1, "r2 As==10");
|
|
|
|
return c2;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
sprintf (op1, "#2");
|
|
|
|
sprintf (comm1, "r3 As==10");
|
|
|
|
return c3;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Indexed register mode @Rn. */
|
|
|
|
sprintf (op1, "@r%d", regno);
|
|
|
|
return cd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
print_as3_reg_name (int regno, char * op1, char * comm1,
|
|
|
|
int c2, int c3, int cd)
|
|
|
|
{
|
|
|
|
switch (regno)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
sprintf (op1, "#8");
|
|
|
|
sprintf (comm1, "r2 As==11");
|
|
|
|
return c2;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
sprintf (op1, "#-1");
|
|
|
|
sprintf (comm1, "r3 As==11");
|
|
|
|
return c3;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Post incremented @Rn+. */
|
|
|
|
sprintf (op1, "@r%d+", regno);
|
|
|
|
return cd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
static int
|
|
|
|
msp430_singleoperand (disassemble_info *info,
|
|
|
|
struct msp430_opcode_s *opcode,
|
|
|
|
bfd_vma addr,
|
|
|
|
unsigned short insn,
|
|
|
|
char *op,
|
|
|
|
char *comm,
|
2013-05-02 23:06:15 +02:00
|
|
|
unsigned short extension_word,
|
2005-07-01 13:16:33 +02:00
|
|
|
int *cycles)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
int regs = 0, regd = 0;
|
|
|
|
int ad = 0, as = 0;
|
|
|
|
int where = 0;
|
|
|
|
int cmd_len = 2;
|
2013-05-02 23:06:15 +02:00
|
|
|
int dst = 0;
|
|
|
|
int fmt;
|
|
|
|
int extended_dst = extension_word & 0xf;
|
2002-12-30 20:25:13 +01:00
|
|
|
|
|
|
|
regd = insn & 0x0f;
|
|
|
|
regs = (insn & 0x0f00) >> 8;
|
|
|
|
as = (insn & 0x0030) >> 4;
|
|
|
|
ad = (insn & 0x0080) >> 7;
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
if (opcode->fmt < 0)
|
|
|
|
fmt = (- opcode->fmt) - 1;
|
|
|
|
else
|
|
|
|
fmt = opcode->fmt;
|
|
|
|
|
|
|
|
switch (fmt)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
case 0: /* Emulated work with dst register. */
|
|
|
|
if (regs != 2 && regs != 3 && regs != 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Check if not clr insn. */
|
|
|
|
if (opcode->bin_opcode == 0x4300 && (ad || as))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Check if really inc, incd insns. */
|
|
|
|
if ((opcode->bin_opcode & 0xff00) == 0x5300 && as == 3)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (ad == 0)
|
|
|
|
{
|
|
|
|
*cycles = 1;
|
|
|
|
|
|
|
|
/* Register. */
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
*cycles += 1;
|
|
|
|
sprintf (op, "r0");
|
|
|
|
}
|
|
|
|
else if (regd == 1)
|
|
|
|
sprintf (op, "r1");
|
|
|
|
|
|
|
|
else if (regd == 2)
|
|
|
|
sprintf (op, "r2");
|
|
|
|
|
|
|
|
else
|
|
|
|
sprintf (op, "r%d", regd);
|
|
|
|
}
|
2005-07-01 13:16:33 +02:00
|
|
|
else /* ad == 1 msp430dis_opcode. */
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
/* PC relative. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
sprintf (op, "0x%04x", dst);
|
|
|
|
sprintf (comm, "PC rel. abs addr 0x%04x",
|
|
|
|
PS ((short) (addr + 2) + dst));
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op, "0x%05x", dst);
|
|
|
|
sprintf (comm, "PC rel. abs addr 0x%05lx",
|
|
|
|
(long)((addr + 2 + dst) & 0xfffff));
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regd == 2)
|
|
|
|
{
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
sprintf (op, "&0x%04x", PS (dst));
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op, "&0x%05x", dst & 0xfffff);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
}
|
|
|
|
sprintf (op, "%d(r%d)", dst, regd);
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* rrc, push, call, swpb, rra, sxt, push, call, reti etc... */
|
|
|
|
if (as == 0)
|
|
|
|
{
|
|
|
|
if (regd == 3)
|
|
|
|
{
|
|
|
|
/* Constsnts. */
|
|
|
|
sprintf (op, "#0");
|
|
|
|
sprintf (comm, "r3 As==00");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Register. */
|
|
|
|
sprintf (op, "r%d", regd);
|
|
|
|
}
|
|
|
|
*cycles = 1;
|
|
|
|
}
|
|
|
|
else if (as == 2)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as2_reg_name (regd, op, comm, 1, 1, 3);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 3)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
if (regd == 0)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
*cycles = 3;
|
|
|
|
/* absolute. @pc+ */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
2013-05-02 23:06:15 +02:00
|
|
|
sprintf (op, "#%d", dst);
|
|
|
|
if (dst > 9 || dst < 0)
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm, "#0x%04x", PS (dst));
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
sprintf (op, "#%d", dst);
|
|
|
|
if (dst > 9 || dst < 0)
|
|
|
|
sprintf (comm, "#0x%05x", dst);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as3_reg_name (regd, op, comm, 1, 1, 3);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 1)
|
|
|
|
{
|
|
|
|
*cycles = 4;
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
/* PC relative. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op, "0x%04x", PS (dst));
|
|
|
|
sprintf (comm, "PC rel. 0x%04x",
|
|
|
|
PS ((short) addr + 2 + dst));
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op, "0x%05x", dst & 0xffff);
|
|
|
|
sprintf (comm, "PC rel. 0x%05lx",
|
|
|
|
(long)((addr + 2 + dst) & 0xfffff));
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regd == 2)
|
|
|
|
{
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op, "&0x%04x", PS (dst));
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op, "&0x%05x", dst & 0xfffff);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regd == 3)
|
|
|
|
{
|
|
|
|
*cycles = 1;
|
|
|
|
sprintf (op, "#1");
|
|
|
|
sprintf (comm, "r3 As==01");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
/* Indexed. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
if (extended_dst)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
}
|
|
|
|
sprintf (op, "%d(r%d)", dst, regd);
|
|
|
|
if (dst > 9 || dst < 0)
|
|
|
|
sprintf (comm, "%05x", dst);
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Jumps. */
|
|
|
|
where = insn & 0x03ff;
|
|
|
|
if (where & 0x200)
|
|
|
|
where |= ~0x03ff;
|
|
|
|
if (where > 512 || where < -511)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
where *= 2;
|
|
|
|
sprintf (op, "$%+-8d", where + 2);
|
2013-05-02 23:06:15 +02:00
|
|
|
sprintf (comm, "abs 0x%lx", (long) (addr + 2 + where));
|
2002-12-30 20:25:13 +01:00
|
|
|
*cycles = 2;
|
|
|
|
return 2;
|
|
|
|
break;
|
2016-05-27 14:49:58 +02:00
|
|
|
|
2002-12-30 20:25:13 +01:00
|
|
|
default:
|
|
|
|
cmd_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd_len;
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
static int
|
|
|
|
msp430_doubleoperand (disassemble_info *info,
|
|
|
|
struct msp430_opcode_s *opcode,
|
|
|
|
bfd_vma addr,
|
|
|
|
unsigned short insn,
|
|
|
|
char *op1,
|
|
|
|
char *op2,
|
|
|
|
char *comm1,
|
|
|
|
char *comm2,
|
2013-05-02 23:06:15 +02:00
|
|
|
unsigned short extension_word,
|
2005-07-01 13:16:33 +02:00
|
|
|
int *cycles)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
int regs = 0, regd = 0;
|
|
|
|
int ad = 0, as = 0;
|
|
|
|
int cmd_len = 2;
|
2013-05-02 23:06:15 +02:00
|
|
|
int dst = 0;
|
|
|
|
int fmt;
|
|
|
|
int extended_dst = extension_word & 0xf;
|
|
|
|
int extended_src = (extension_word >> 7) & 0xf;
|
2002-12-30 20:25:13 +01:00
|
|
|
|
|
|
|
regd = insn & 0x0f;
|
|
|
|
regs = (insn & 0x0f00) >> 8;
|
|
|
|
as = (insn & 0x0030) >> 4;
|
|
|
|
ad = (insn & 0x0080) >> 7;
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
if (opcode->fmt < 0)
|
|
|
|
fmt = (- opcode->fmt) - 1;
|
|
|
|
else
|
|
|
|
fmt = opcode->fmt;
|
|
|
|
|
|
|
|
if (fmt == 0)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
/* Special case: rla and rlc are the only 2 emulated instructions that
|
|
|
|
fall into two operand instructions. */
|
|
|
|
/* With dst, there are only:
|
|
|
|
Rm Register,
|
|
|
|
x(Rm) Indexed,
|
|
|
|
0xXXXX Relative,
|
2015-08-12 13:45:07 +02:00
|
|
|
&0xXXXX Absolute
|
2002-12-30 20:25:13 +01:00
|
|
|
emulated_ins dst
|
|
|
|
basic_ins dst, dst. */
|
|
|
|
|
|
|
|
if (regd != regs || as != ad)
|
|
|
|
return 0; /* May be 'data' section. */
|
|
|
|
|
|
|
|
if (ad == 0)
|
|
|
|
{
|
|
|
|
/* Register mode. */
|
|
|
|
if (regd == 3)
|
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
strcpy (comm1, _("Warning: illegal as emulation instr"));
|
2002-12-30 20:25:13 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf (op1, "r%d", regd);
|
|
|
|
*cycles = 1;
|
|
|
|
}
|
|
|
|
else /* ad == 1 */
|
|
|
|
{
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
/* PC relative, Symbolic. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 4;
|
|
|
|
*cycles = 6;
|
|
|
|
sprintf (op1, "0x%04x", PS (dst));
|
|
|
|
sprintf (comm1, "PC rel. 0x%04x",
|
|
|
|
PS ((short) addr + 2 + dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
sprintf (op1, "0x%05x", dst & 0xfffff);
|
|
|
|
sprintf (comm1, "PC rel. 0x%05lx",
|
|
|
|
(long)((addr + 2 + dst) & 0xfffff));
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regd == 2)
|
|
|
|
{
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
int src;
|
|
|
|
|
|
|
|
/* If the 'src' field is not the same as the dst
|
|
|
|
then this is not an rla instruction. */
|
|
|
|
if (msp430dis_opcode_signed (addr + 4, info, &src, comm2))
|
|
|
|
{
|
|
|
|
if (src != dst)
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 4;
|
|
|
|
*cycles = 6;
|
|
|
|
sprintf (op1, "&0x%04x", PS (dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op1, "&0x%05x", dst & 0xfffff);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Indexed. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
}
|
|
|
|
cmd_len += 4;
|
|
|
|
*cycles = 6;
|
|
|
|
sprintf (op1, "%d(r%d)", dst, regd);
|
|
|
|
if (dst > 9 || dst < -9)
|
|
|
|
sprintf (comm1, "#0x%05x", dst);
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*op2 = 0;
|
|
|
|
*comm2 = 0;
|
2013-05-02 23:06:15 +02:00
|
|
|
|
2002-12-30 20:25:13 +01:00
|
|
|
return cmd_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Two operands exactly. */
|
|
|
|
if (ad == 0 && regd == 3)
|
|
|
|
{
|
|
|
|
/* R2/R3 are illegal as dest: may be data section. */
|
2016-05-27 14:49:58 +02:00
|
|
|
strcpy (comm1, _("Warning: illegal as 2-op instr"));
|
2002-12-30 20:25:13 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Source. */
|
|
|
|
if (as == 0)
|
|
|
|
{
|
|
|
|
*cycles = 1;
|
|
|
|
if (regs == 3)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
/* Constants. */
|
2002-12-30 20:25:13 +01:00
|
|
|
sprintf (op1, "#0");
|
|
|
|
sprintf (comm1, "r3 As==00");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Register. */
|
|
|
|
sprintf (op1, "r%d", regs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (as == 2)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as2_reg_name (regs, op1, comm1, 1, 1, regs == 0 ? 3 : 2);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 3)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
if (regs == 0)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
*cycles = 3;
|
2005-07-01 13:16:33 +02:00
|
|
|
/* Absolute. @pc+. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
2013-05-02 23:06:15 +02:00
|
|
|
sprintf (op1, "#%d", dst);
|
|
|
|
if (dst > 9 || dst < 0)
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm1, "#0x%04x", PS (dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst &= 0xffff;
|
|
|
|
dst |= extended_src << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
sprintf (op1, "#%d", dst);
|
|
|
|
if (dst > 9 || dst < 0)
|
|
|
|
sprintf (comm1, "0x%05x", dst & 0xfffff);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as3_reg_name (regs, op1, comm1, 1, 1, 2);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 1)
|
|
|
|
{
|
|
|
|
if (regs == 0)
|
|
|
|
{
|
|
|
|
*cycles = 4;
|
|
|
|
/* PC relative. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "0x%04x", PS (dst));
|
|
|
|
sprintf (comm1, "PC rel. 0x%04x",
|
|
|
|
PS ((short) addr + 2 + dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst &= 0xffff;
|
|
|
|
dst |= extended_src << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
sprintf (op1, "0x%05x", dst & 0xfffff);
|
|
|
|
sprintf (comm1, "PC rel. 0x%05lx",
|
|
|
|
(long) ((addr + 2 + dst) & 0xfffff));
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regs == 2)
|
|
|
|
{
|
|
|
|
*cycles = 2;
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "&0x%04x", PS (dst));
|
|
|
|
sprintf (comm1, "0x%04x", PS (dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst &= 0xffff;
|
|
|
|
dst |= extended_src << 16;
|
|
|
|
sprintf (op1, "&0x%05x", dst & 0xfffff);
|
|
|
|
* comm1 = 0;
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regs == 3)
|
|
|
|
{
|
|
|
|
*cycles = 1;
|
|
|
|
sprintf (op1, "#1");
|
|
|
|
sprintf (comm1, "r3 As==01");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*cycles = 3;
|
|
|
|
/* Indexed. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst &= 0xffff;
|
|
|
|
dst |= extended_src << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
}
|
|
|
|
sprintf (op1, "%d(r%d)", dst, regs);
|
|
|
|
if (dst > 9 || dst < -9)
|
|
|
|
sprintf (comm1, "0x%05x", dst);
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destination. Special care needed on addr + XXXX. */
|
|
|
|
|
|
|
|
if (ad == 0)
|
|
|
|
{
|
|
|
|
/* Register. */
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
*cycles += 1;
|
|
|
|
sprintf (op2, "r0");
|
|
|
|
}
|
|
|
|
else if (regd == 1)
|
|
|
|
sprintf (op2, "r1");
|
|
|
|
|
|
|
|
else if (regd == 2)
|
|
|
|
sprintf (op2, "r2");
|
|
|
|
|
|
|
|
else
|
|
|
|
sprintf (op2, "r%d", regd);
|
|
|
|
}
|
2005-07-01 13:16:33 +02:00
|
|
|
else /* ad == 1. */
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
* cycles += 3;
|
|
|
|
|
|
|
|
if (regd == 0)
|
|
|
|
{
|
|
|
|
/* PC relative. */
|
|
|
|
*cycles += 1;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + cmd_len, info, &dst, comm2))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (op2, "0x%04x", PS (dst));
|
|
|
|
sprintf (comm2, "PC rel. 0x%04x",
|
|
|
|
PS ((short) addr + cmd_len + dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
sprintf (op2, "0x%05x", dst & 0xfffff);
|
|
|
|
sprintf (comm2, "PC rel. 0x%05lx",
|
|
|
|
(long)((addr + cmd_len + dst) & 0xfffff));
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
cmd_len += 2;
|
|
|
|
}
|
|
|
|
else if (regd == 2)
|
|
|
|
{
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + cmd_len, info, &dst, comm2))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op2, "&0x%04x", PS (dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
sprintf (op2, "&0x%05x", dst & 0xfffff);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + cmd_len, info, &dst, comm2))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
cmd_len += 2;
|
2013-05-02 23:06:15 +02:00
|
|
|
if (dst > 9 || dst < 0)
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm2, "0x%04x", PS (dst));
|
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
dst |= extended_dst << 16;
|
|
|
|
if (dst & 0x80000)
|
|
|
|
dst |= -1U << 20;
|
|
|
|
if (dst > 9 || dst < 0)
|
|
|
|
sprintf (comm2, "0x%05x", dst & 0xfffff);
|
|
|
|
}
|
|
|
|
sprintf (op2, "%d(r%d)", dst, regd);
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd_len;
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
static int
|
|
|
|
msp430_branchinstr (disassemble_info *info,
|
|
|
|
struct msp430_opcode_s *opcode ATTRIBUTE_UNUSED,
|
|
|
|
bfd_vma addr ATTRIBUTE_UNUSED,
|
|
|
|
unsigned short insn,
|
|
|
|
char *op1,
|
|
|
|
char *comm1,
|
|
|
|
int *cycles)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
int regs = 0, regd = 0;
|
2010-06-27 06:07:55 +02:00
|
|
|
int as = 0;
|
2002-12-30 20:25:13 +01:00
|
|
|
int cmd_len = 2;
|
2016-05-27 14:49:58 +02:00
|
|
|
int dst = 0;
|
|
|
|
unsigned short udst = 0;
|
2002-12-30 20:25:13 +01:00
|
|
|
|
|
|
|
regd = insn & 0x0f;
|
|
|
|
regs = (insn & 0x0f00) >> 8;
|
|
|
|
as = (insn & 0x0030) >> 4;
|
|
|
|
|
|
|
|
if (regd != 0) /* Destination register is not a PC. */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* dst is a source register. */
|
|
|
|
if (as == 0)
|
|
|
|
{
|
|
|
|
/* Constants. */
|
|
|
|
if (regs == 3)
|
|
|
|
{
|
|
|
|
*cycles = 1;
|
|
|
|
sprintf (op1, "#0");
|
|
|
|
sprintf (comm1, "r3 As==00");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Register. */
|
|
|
|
*cycles = 1;
|
|
|
|
sprintf (op1, "r%d", regs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (as == 2)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as2_reg_name (regs, op1, comm1, 2, 1, 2);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 3)
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
if (regs == 0)
|
2002-12-30 20:25:13 +01:00
|
|
|
{
|
|
|
|
/* Absolute. @pc+ */
|
|
|
|
*cycles = 3;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &udst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "#0x%04x", PS (udst));
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else
|
2013-05-02 23:06:15 +02:00
|
|
|
* cycles = print_as3_reg_name (regs, op1, comm1, 1, 1, 2);
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (as == 1)
|
|
|
|
{
|
|
|
|
* cycles = 3;
|
|
|
|
|
|
|
|
if (regs == 0)
|
|
|
|
{
|
|
|
|
/* PC relative. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
(*cycles)++;
|
|
|
|
sprintf (op1, "0x%04x", PS (dst));
|
|
|
|
sprintf (comm1, "PC rel. 0x%04x",
|
|
|
|
PS ((short) addr + 2 + dst));
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regs == 2)
|
|
|
|
{
|
|
|
|
/* Absolute. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &udst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "&0x%04x", PS (udst));
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
else if (regs == 3)
|
|
|
|
{
|
|
|
|
(*cycles)--;
|
|
|
|
sprintf (op1, "#1");
|
|
|
|
sprintf (comm1, "r3 As==01");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-02 23:06:15 +02:00
|
|
|
/* Indexed. */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "%d(r%d)", dst, regs);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2002-12-30 20:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd_len;
|
|
|
|
}
|
2005-07-01 13:16:33 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
static int
|
|
|
|
msp430x_calla_instr (disassemble_info * info,
|
|
|
|
bfd_vma addr,
|
|
|
|
unsigned short insn,
|
|
|
|
char * op1,
|
|
|
|
char * comm1,
|
|
|
|
int * cycles)
|
|
|
|
{
|
|
|
|
unsigned int ureg = insn & 0xf;
|
|
|
|
int reg = insn & 0xf;
|
|
|
|
int am = (insn & 0xf0) >> 4;
|
|
|
|
int cmd_len = 2;
|
|
|
|
unsigned short udst = 0;
|
2016-05-27 14:49:58 +02:00
|
|
|
int dst = 0;
|
2013-05-02 23:06:15 +02:00
|
|
|
|
|
|
|
switch (am)
|
|
|
|
{
|
|
|
|
case 4: /* CALLA Rdst */
|
|
|
|
*cycles = 1;
|
|
|
|
sprintf (op1, "r%d", reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: /* CALLA x(Rdst) */
|
|
|
|
*cycles = 3;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
sprintf (op1, "%d(r%d)", dst, reg);
|
|
|
|
if (reg == 0)
|
|
|
|
sprintf (comm1, "PC rel. 0x%05lx", (long) (addr + 2 + dst));
|
|
|
|
else
|
|
|
|
sprintf (comm1, "0x%05x", dst);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: /* CALLA @Rdst */
|
|
|
|
*cycles = 2;
|
|
|
|
sprintf (op1, "@r%d", reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: /* CALLA @Rdst+ */
|
|
|
|
*cycles = 2;
|
|
|
|
sprintf (op1, "@r%d+", reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: /* CALLA &abs20 */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &udst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
sprintf (op1, "&%d", (ureg << 16) + udst);
|
|
|
|
sprintf (comm1, "0x%05x", (ureg << 16) + udst);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 9: /* CALLA pcrel-sym */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &dst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
sprintf (op1, "%d(PC)", (reg << 16) + dst);
|
|
|
|
sprintf (comm1, "PC rel. 0x%05lx",
|
|
|
|
(long) (addr + 2 + dst + (reg << 16)));
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 11: /* CALLA #imm20 */
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &udst, comm1))
|
|
|
|
{
|
|
|
|
cmd_len += 2;
|
|
|
|
*cycles = 4;
|
|
|
|
sprintf (op1, "#%d", (ureg << 16) + udst);
|
|
|
|
sprintf (comm1, "0x%05x", (ureg << 16) + udst);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-05-27 14:49:58 +02:00
|
|
|
strcpy (comm1, _("Warning: unrecognised CALLA addressing mode"));
|
2013-05-02 23:06:15 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd_len;
|
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
int
|
|
|
|
print_insn_msp430 (bfd_vma addr, disassemble_info *info)
|
|
|
|
{
|
|
|
|
void *stream = info->stream;
|
|
|
|
fprintf_ftype prin = info->fprintf_func;
|
|
|
|
struct msp430_opcode_s *opcode;
|
|
|
|
char op1[32], op2[32], comm1[64], comm2[64];
|
|
|
|
int cmd_len = 0;
|
|
|
|
unsigned short insn;
|
|
|
|
int cycles = 0;
|
|
|
|
char *bc = "";
|
2013-05-02 23:06:15 +02:00
|
|
|
unsigned short extension_word = 0;
|
2016-05-27 14:49:58 +02:00
|
|
|
unsigned short bits;
|
2005-07-01 13:16:33 +02:00
|
|
|
|
2016-05-27 14:49:58 +02:00
|
|
|
if (! msp430dis_opcode_unsigned (addr, info, &insn, NULL))
|
2017-01-12 10:40:41 +01:00
|
|
|
return -1;
|
2005-07-01 13:16:33 +02:00
|
|
|
|
|
|
|
if (((int) addr & 0xffff) > 0xffdf)
|
|
|
|
{
|
|
|
|
(*prin) (stream, "interrupt service routine at 0x%04x", 0xffff & insn);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
*comm1 = 0;
|
|
|
|
*comm2 = 0;
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
/* Check for an extension word. */
|
|
|
|
if ((insn & 0xf800) == 0x1800)
|
|
|
|
{
|
|
|
|
extension_word = insn;
|
|
|
|
addr += 2;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (! msp430dis_opcode_unsigned (addr, info, &insn, NULL))
|
2017-01-12 10:40:41 +01:00
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
for (opcode = msp430_opcodes; opcode->name; opcode++)
|
|
|
|
{
|
|
|
|
if ((insn & opcode->bin_mask) == opcode->bin_opcode
|
|
|
|
&& opcode->bin_opcode != 0x9300)
|
|
|
|
{
|
|
|
|
*op1 = 0;
|
|
|
|
*op2 = 0;
|
|
|
|
*comm1 = 0;
|
|
|
|
*comm2 = 0;
|
|
|
|
|
|
|
|
/* r0 as destination. Ad should be zero. */
|
2013-05-02 23:06:15 +02:00
|
|
|
if (opcode->insn_opnumb == 3
|
|
|
|
&& (insn & 0x000f) == 0
|
|
|
|
&& (insn & 0x0080) == 0)
|
2005-07-01 13:16:33 +02:00
|
|
|
{
|
2017-01-12 10:40:41 +01:00
|
|
|
int ret =
|
2005-07-01 13:16:33 +02:00
|
|
|
msp430_branchinstr (info, opcode, addr, insn, op1, comm1,
|
|
|
|
&cycles);
|
2017-01-12 10:40:41 +01:00
|
|
|
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
cmd_len += ret;
|
2005-07-01 13:16:33 +02:00
|
|
|
if (cmd_len)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
switch (opcode->insn_opnumb)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
int reg;
|
2017-01-12 10:40:41 +01:00
|
|
|
int ret;
|
2013-05-02 23:06:15 +02:00
|
|
|
|
|
|
|
case 4:
|
2017-01-12 10:40:41 +01:00
|
|
|
ret = msp430x_calla_instr (info, addr, insn,
|
|
|
|
op1, comm1, & cycles);
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
cmd_len += ret;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: /* PUSHM/POPM */
|
|
|
|
n = (insn & 0xf0) >> 4;
|
|
|
|
reg = (insn & 0xf);
|
|
|
|
|
|
|
|
sprintf (op1, "#%d", n + 1);
|
|
|
|
if (opcode->bin_opcode == 0x1400)
|
|
|
|
/* PUSHM */
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
else
|
|
|
|
/* POPM */
|
|
|
|
sprintf (op2, "r%d", reg + n);
|
|
|
|
if (insn & 0x100)
|
|
|
|
sprintf (comm1, "16-bit words");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf (comm1, "20-bit words");
|
|
|
|
bc =".a";
|
|
|
|
}
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
cycles = 2; /*FIXME*/
|
|
|
|
cmd_len = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: /* RRAM, RRCM, RRUM, RLAM. */
|
|
|
|
n = ((insn >> 10) & 0x3) + 1;
|
|
|
|
reg = (insn & 0xf);
|
|
|
|
if ((insn & 0x10) == 0)
|
|
|
|
bc =".a";
|
|
|
|
sprintf (op1, "#%d", n);
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
cycles = 2; /*FIXME*/
|
|
|
|
cmd_len = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: /* ADDA, CMPA, SUBA. */
|
|
|
|
reg = (insn & 0xf);
|
|
|
|
n = (insn >> 8) & 0xf;
|
|
|
|
if (insn & 0x40)
|
|
|
|
{
|
|
|
|
sprintf (op1, "r%d", n);
|
|
|
|
cmd_len = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n <<= 16;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &bits, comm1))
|
|
|
|
{
|
|
|
|
n |= bits;
|
|
|
|
sprintf (op1, "#%d", n);
|
|
|
|
if (n > 9 || n < 0)
|
|
|
|
sprintf (comm1, "0x%05x", n);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
cmd_len = 4;
|
|
|
|
}
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
cycles = 2; /*FIXME*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9: /* MOVA */
|
|
|
|
reg = (insn & 0xf);
|
|
|
|
n = (insn >> 8) & 0xf;
|
|
|
|
switch ((insn >> 4) & 0xf)
|
|
|
|
{
|
|
|
|
case 0: /* MOVA @Rsrc, Rdst */
|
|
|
|
cmd_len = 2;
|
|
|
|
sprintf (op1, "@r%d", n);
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
break;
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
case 1: /* MOVA @Rsrc+, Rdst */
|
|
|
|
cmd_len = 2;
|
|
|
|
if (strcmp (opcode->name, "reta") != 0)
|
|
|
|
{
|
|
|
|
sprintf (op1, "@r%d+", n);
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
}
|
|
|
|
break;
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
case 2: /* MOVA &abs20, Rdst */
|
|
|
|
cmd_len = 4;
|
|
|
|
n <<= 16;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &bits, comm1))
|
|
|
|
{
|
|
|
|
n |= bits;
|
|
|
|
sprintf (op1, "&%d", n);
|
|
|
|
if (n > 9 || n < 0)
|
|
|
|
sprintf (comm1, "0x%05x", n);
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
case 3: /* MOVA x(Rsrc), Rdst */
|
|
|
|
cmd_len = 4;
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
reg = n;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &n, comm1))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (op1, "%d(r%d)", n, reg);
|
|
|
|
if (n > 9 || n < 0)
|
|
|
|
{
|
|
|
|
if (reg == 0)
|
|
|
|
sprintf (comm1, "PC rel. 0x%05lx",
|
|
|
|
(long) (addr + 2 + n));
|
|
|
|
else
|
|
|
|
sprintf (comm1, "0x%05x", n);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: /* MOVA Rsrc, &abs20 */
|
|
|
|
cmd_len = 4;
|
|
|
|
reg <<= 16;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &bits, comm2))
|
|
|
|
{
|
|
|
|
reg |= bits;
|
|
|
|
sprintf (op1, "r%d", n);
|
|
|
|
sprintf (op2, "&%d", reg);
|
|
|
|
if (reg > 9 || reg < 0)
|
|
|
|
sprintf (comm2, "0x%05x", reg);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: /* MOVA Rsrc, x(Rdst) */
|
|
|
|
cmd_len = 4;
|
|
|
|
sprintf (op1, "r%d", n);
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_signed (addr + 2, info, &n, comm2))
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (op2, "%d(r%d)", n, reg);
|
|
|
|
if (n > 9 || n < 0)
|
|
|
|
{
|
|
|
|
if (reg == 0)
|
|
|
|
sprintf (comm2, "PC rel. 0x%05lx",
|
|
|
|
(long) (addr + 2 + n));
|
|
|
|
else
|
|
|
|
sprintf (comm2, "0x%05x", n);
|
|
|
|
}
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
case 8: /* MOVA #imm20, Rdst */
|
|
|
|
cmd_len = 4;
|
|
|
|
n <<= 16;
|
2016-05-27 14:49:58 +02:00
|
|
|
if (msp430dis_opcode_unsigned (addr + 2, info, &bits, comm1))
|
|
|
|
{
|
|
|
|
n |= bits;
|
|
|
|
if (n & 0x80000)
|
|
|
|
n |= -1U << 20;
|
|
|
|
sprintf (op1, "#%d", n);
|
|
|
|
if (n > 9 || n < 0)
|
|
|
|
sprintf (comm1, "0x%05x", n);
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
}
|
2017-01-12 10:40:41 +01:00
|
|
|
else
|
|
|
|
return -1;
|
2013-05-02 23:06:15 +02:00
|
|
|
break;
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
case 12: /* MOVA Rsrc, Rdst */
|
|
|
|
cmd_len = 2;
|
|
|
|
sprintf (op1, "r%d", n);
|
|
|
|
if (strcmp (opcode->name, "bra") != 0)
|
|
|
|
sprintf (op2, "r%d", reg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cycles = 2; /* FIXME */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd_len)
|
|
|
|
break;
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
switch (opcode->insn_opnumb)
|
|
|
|
{
|
2017-01-12 10:40:41 +01:00
|
|
|
int ret;
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
case 0:
|
2013-05-02 23:06:15 +02:00
|
|
|
cmd_len += msp430_nooperands (opcode, addr, insn, comm1, &cycles);
|
2005-07-01 13:16:33 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-01-12 10:40:41 +01:00
|
|
|
ret =
|
2005-07-01 13:16:33 +02:00
|
|
|
msp430_doubleoperand (info, opcode, addr, insn, op1, op2,
|
2013-05-02 23:06:15 +02:00
|
|
|
comm1, comm2,
|
|
|
|
extension_word,
|
|
|
|
&cycles);
|
2017-01-12 10:40:41 +01:00
|
|
|
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
cmd_len += ret;
|
2005-07-01 13:16:33 +02:00
|
|
|
if (insn & BYTE_OPERATION)
|
2013-05-02 23:06:15 +02:00
|
|
|
{
|
|
|
|
if (extension_word != 0 && ((extension_word & BYTE_OPERATION) == 0))
|
|
|
|
bc = ".a";
|
|
|
|
else
|
|
|
|
bc = ".b";
|
|
|
|
}
|
|
|
|
else if (extension_word)
|
|
|
|
{
|
2016-02-04 10:55:10 +01:00
|
|
|
if (extension_word & BYTE_OPERATION)
|
2013-05-02 23:06:15 +02:00
|
|
|
bc = ".w";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bc = ".?";
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm2, _("Warning: reserved use of A/L and B/W bits detected"));
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-12 13:45:07 +02:00
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-12 10:40:41 +01:00
|
|
|
ret =
|
2005-07-01 13:16:33 +02:00
|
|
|
msp430_singleoperand (info, opcode, addr, insn, op1, comm1,
|
2013-05-02 23:06:15 +02:00
|
|
|
extension_word,
|
2005-07-01 13:16:33 +02:00
|
|
|
&cycles);
|
2017-01-12 10:40:41 +01:00
|
|
|
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
cmd_len += ret;
|
2013-05-02 23:06:15 +02:00
|
|
|
if (extension_word
|
|
|
|
&& (strcmp (opcode->name, "swpb") == 0
|
|
|
|
|| strcmp (opcode->name, "sxt") == 0))
|
|
|
|
{
|
|
|
|
if (insn & BYTE_OPERATION)
|
|
|
|
{
|
|
|
|
bc = ".?";
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm2, _("Warning: reserved use of A/L and B/W bits detected"));
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
|
|
|
else if (extension_word & BYTE_OPERATION)
|
|
|
|
bc = ".w";
|
|
|
|
else
|
|
|
|
bc = ".a";
|
|
|
|
}
|
|
|
|
else if (insn & BYTE_OPERATION && opcode->fmt != 3)
|
|
|
|
{
|
|
|
|
if (extension_word != 0 && ((extension_word & BYTE_OPERATION) == 0))
|
|
|
|
bc = ".a";
|
|
|
|
else
|
|
|
|
bc = ".b";
|
|
|
|
}
|
|
|
|
else if (extension_word)
|
|
|
|
{
|
|
|
|
if (extension_word & (1 << 6))
|
|
|
|
bc = ".w";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bc = ".?";
|
2016-05-27 14:49:58 +02:00
|
|
|
sprintf (comm2, _("Warning: reserved use of A/L and B/W bits detected"));
|
2013-05-02 23:06:15 +02:00
|
|
|
}
|
|
|
|
}
|
2005-07-01 13:16:33 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd_len)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd_len < 1)
|
|
|
|
{
|
|
|
|
/* Unknown opcode, or invalid combination of operands. */
|
2013-05-02 23:06:15 +02:00
|
|
|
if (extension_word)
|
|
|
|
{
|
|
|
|
prin (stream, ".word 0x%04x, 0x%04x; ????", extension_word, PS (insn));
|
|
|
|
if (*comm1)
|
|
|
|
prin (stream, "\t %s", comm1);
|
|
|
|
return 4;
|
|
|
|
}
|
2005-07-01 13:16:33 +02:00
|
|
|
(*prin) (stream, ".word 0x%04x; ????", PS (insn));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2013-05-02 23:06:15 +02:00
|
|
|
/* Display the repeat count (if set) for extended register mode. */
|
|
|
|
if (cmd_len == 2 && ((extension_word & 0xf) != 0))
|
|
|
|
{
|
|
|
|
if (extension_word & (1 << 7))
|
|
|
|
prin (stream, "rpt r%d { ", extension_word & 0xf);
|
|
|
|
else
|
|
|
|
prin (stream, "rpt #%d { ", (extension_word & 0xf) + 1);
|
|
|
|
}
|
|
|
|
|
2016-02-04 10:55:10 +01:00
|
|
|
/* Special case: RRC with an extension word and the ZC bit set is actually RRU. */
|
|
|
|
if (extension_word
|
|
|
|
&& (extension_word & IGNORE_CARRY_BIT)
|
|
|
|
&& strcmp (opcode->name, "rrc") == 0)
|
|
|
|
(*prin) (stream, "rrux%s", bc);
|
|
|
|
else if (extension_word && opcode->name[strlen (opcode->name) - 1] != 'x')
|
2013-05-02 23:06:15 +02:00
|
|
|
(*prin) (stream, "%sx%s", opcode->name, bc);
|
|
|
|
else
|
|
|
|
(*prin) (stream, "%s%s", opcode->name, bc);
|
2005-07-01 13:16:33 +02:00
|
|
|
|
|
|
|
if (*op1)
|
|
|
|
(*prin) (stream, "\t%s", op1);
|
|
|
|
if (*op2)
|
|
|
|
(*prin) (stream, ",");
|
|
|
|
|
|
|
|
if (strlen (op1) < 7)
|
|
|
|
(*prin) (stream, "\t");
|
|
|
|
if (!strlen (op1))
|
|
|
|
(*prin) (stream, "\t");
|
|
|
|
|
|
|
|
if (*op2)
|
|
|
|
(*prin) (stream, "%s", op2);
|
|
|
|
if (strlen (op2) < 8)
|
|
|
|
(*prin) (stream, "\t");
|
|
|
|
|
|
|
|
if (*comm1 || *comm2)
|
|
|
|
(*prin) (stream, ";");
|
|
|
|
else if (cycles)
|
|
|
|
{
|
|
|
|
if (*op2)
|
|
|
|
(*prin) (stream, ";");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strlen (op1) < 7)
|
|
|
|
(*prin) (stream, ";");
|
|
|
|
else
|
|
|
|
(*prin) (stream, "\t;");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*comm1)
|
|
|
|
(*prin) (stream, "%s", comm1);
|
|
|
|
if (*comm1 && *comm2)
|
|
|
|
(*prin) (stream, ",");
|
|
|
|
if (*comm2)
|
|
|
|
(*prin) (stream, " %s", comm2);
|
2013-05-02 23:06:15 +02:00
|
|
|
|
|
|
|
if (extension_word)
|
|
|
|
cmd_len += 2;
|
|
|
|
|
2005-07-01 13:16:33 +02:00
|
|
|
return cmd_len;
|
|
|
|
}
|