mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
dc1e8a474f
Labels don't go in the first column according to standard emacs C indent rules, and I got annoyed enough at seeing diff -p show a label rather than the function name to fix this. bfd/ * aoutx.h: Indent labels correctly. Format error strings. * archive.c: Likewise. * archive64.c: Likewise. * coff-arm.c: Likewise. * coff-rs6000.c: Likewise. * coff-stgo32.c: Likewise. * cpu-arm.c: Likewise. * dwarf2.c: Likewise. * elf-ifunc.c: Likewise. * elf-properties.c: Likewise. * elf-s390-common.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-bfin.c: Likewise. * elf32-cr16.c: Likewise. * elf32-csky.c: Likewise. * elf32-i386.c: Likewise. * elf32-m68k.c: Likewise. * elf32-msp430.c: Likewise. * elf32-nds32.c: Likewise. * elf32-nios2.c: Likewise. * elf32-pru.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-ia64-vms.c: Likewise. * elf64-x86-64.c: Likewise. * elfcode.h: Likewise. * elfcore.h: Likewise. * elflink.c: Likewise. * elfnn-aarch64.c: Likewise. * elfnn-ia64.c: Likewise. * elfnn-riscv.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * elfxx-x86.c: Likewise. * i386lynx.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * plugin.c: Likewise. * reloc.c: Likewise. binutils/ * elfedit.c: Indent labels correctly. * readelf.c: Likewise. * resres.c: Likewise. gas/ * config/obj-elf.c: Indent labels correctly. * config/obj-macho.c: Likewise. * config/tc-aarch64.c: Likewise. * config/tc-alpha.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-cr16.c: Likewise. * config/tc-crx.c: Likewise. * config/tc-frv.c: Likewise. * config/tc-i386-intel.c: Likewise. * config/tc-i386.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-mn10200.c: Likewise. * config/tc-mn10300.c: Likewise. * config/tc-nds32.c: Likewise. * config/tc-riscv.c: Likewise. * config/tc-s12z.c: Likewise. * config/tc-xtensa.c: Likewise. * config/tc-z80.c: Likewise. * read.c: Likewise. * symbols.c: Likewise. * write.c: Likewise. ld/ * emultempl/cskyelf.em: Indent labels correctly. * ldfile.c: Likewise. * ldlang.c: Likewise. * plugin.c: Likewise. opcodes/ * aarch64-asm.c: Indent labels correctly. * aarch64-dis.c: Likewise. * aarch64-gen.c: Likewise. * aarch64-opc.c: Likewise. * alpha-dis.c: Likewise. * i386-dis.c: Likewise. * nds32-asm.c: Likewise. * nfp-dis.c: Likewise. * visium-dis.c: Likewise.
835 lines
20 KiB
C
835 lines
20 KiB
C
/* Single instruction disassembler for the Visium.
|
|
|
|
Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU opcodes library.
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
#include "sysdep.h"
|
|
#include "disassemble.h"
|
|
#include "opcode/visium.h"
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <setjmp.h>
|
|
|
|
/* Maximum length of an instruction. */
|
|
#define MAXLEN 4
|
|
|
|
struct private
|
|
{
|
|
/* Points to first byte not fetched. */
|
|
bfd_byte *max_fetched;
|
|
bfd_byte the_buffer[MAXLEN];
|
|
bfd_vma insn_start;
|
|
jmp_buf bailout;
|
|
};
|
|
|
|
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
|
|
to ADDR (exclusive) are valid. Returns 1 for success, longjmps
|
|
on error. */
|
|
#define FETCH_DATA(info, addr) \
|
|
((addr) <= ((struct private *)(info->private_data))->max_fetched \
|
|
? 1 : fetch_data ((info), (addr)))
|
|
|
|
static int fetch_data (struct disassemble_info *info, bfd_byte * addr);
|
|
|
|
static int
|
|
fetch_data (struct disassemble_info *info, bfd_byte *addr)
|
|
{
|
|
int status;
|
|
struct private *priv = (struct private *) info->private_data;
|
|
bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
|
|
|
|
status = (*info->read_memory_func) (start,
|
|
priv->max_fetched,
|
|
addr - priv->max_fetched, info);
|
|
if (status != 0)
|
|
{
|
|
(*info->memory_error_func) (status, start, info);
|
|
longjmp (priv->bailout, 1);
|
|
}
|
|
else
|
|
priv->max_fetched = addr;
|
|
return 1;
|
|
}
|
|
|
|
static char *size_names[] = { "?", "b", "w", "?", "l", "?", "?", "?" };
|
|
|
|
static char *cc_names[] =
|
|
{
|
|
"fa", "eq", "cs", "os", "ns", "ne", "cc", "oc",
|
|
"nc", "ge", "gt", "hi", "le", "ls", "lt", "tr"
|
|
};
|
|
|
|
/* Disassemble non-storage relative instructions. */
|
|
|
|
static int
|
|
disassem_class0 (disassemble_info *info, unsigned int ins)
|
|
{
|
|
int opcode = (ins >> 21) & 0x000f;
|
|
|
|
if (ins & CLASS0_UNUSED_MASK)
|
|
goto illegal_opcode;
|
|
|
|
switch (opcode)
|
|
{
|
|
case 0:
|
|
/* BRR instruction. */
|
|
{
|
|
unsigned cbf = (ins >> 27) & 0x000f;
|
|
int displacement = ((ins & 0xffff) ^ 0x8000) - 0x8000;
|
|
|
|
if (ins == 0)
|
|
(*info->fprintf_func) (info->stream, "nop");
|
|
else
|
|
(*info->fprintf_func) (info->stream, "brr %s,%+d",
|
|
cc_names[cbf], displacement);
|
|
}
|
|
break;
|
|
case 1:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 2:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 3:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 4:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 5:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 6:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 7:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 8:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 9:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 10:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 11:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 12:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 13:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 14:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 15:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
}
|
|
return 0;
|
|
|
|
illegal_opcode:
|
|
return -1;
|
|
}
|
|
|
|
/* Disassemble non-storage register class instructions. */
|
|
|
|
static int
|
|
disassem_class1 (disassemble_info *info, unsigned int ins)
|
|
{
|
|
int opcode = (ins >> 21) & 0xf;
|
|
int source_a = (ins >> 16) & 0x1f;
|
|
int source_b = (ins >> 4) & 0x1f;
|
|
int indx = (ins >> 10) & 0x1f;
|
|
|
|
int size = ins & 0x7;
|
|
|
|
if (ins & CLASS1_UNUSED_MASK)
|
|
goto illegal_opcode;
|
|
|
|
switch (opcode)
|
|
{
|
|
case 0:
|
|
/* Stop. */
|
|
(*info->fprintf_func) (info->stream, "stop %d,r%d", indx, source_a);
|
|
break;
|
|
case 1:
|
|
/* BMI - Block Move Indirect. */
|
|
if (ins != BMI)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "bmi r1,r2,r3");
|
|
break;
|
|
case 2:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 3:
|
|
/* BMD - Block Move Direct. */
|
|
if (ins != BMD)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "bmd r1,r2,r3");
|
|
break;
|
|
case 4:
|
|
/* DSI - Disable Interrupts. */
|
|
if (ins != DSI)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "dsi");
|
|
break;
|
|
|
|
case 5:
|
|
/* ENI - Enable Interrupts. */
|
|
if (ins != ENI)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "eni");
|
|
break;
|
|
|
|
case 6:
|
|
/* Illegal opcode (was EUT). */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 7:
|
|
/* RFI - Return from Interrupt. */
|
|
if (ins != RFI)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "rfi");
|
|
break;
|
|
case 8:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 9:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 10:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 11:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 12:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 13:
|
|
goto illegal_opcode;
|
|
break;
|
|
case 14:
|
|
goto illegal_opcode;
|
|
break;
|
|
case 15:
|
|
if (ins & EAM_SELECT_MASK)
|
|
{
|
|
/* Extension arithmetic module write */
|
|
int fp_ins = (ins >> 27) & 0xf;
|
|
|
|
if (size != 4)
|
|
goto illegal_opcode;
|
|
|
|
if (ins & FP_SELECT_MASK)
|
|
{
|
|
/* Which floating point instructions don't need a fsrcB
|
|
register. */
|
|
const int no_fsrcb[16] = { 1, 0, 0, 0, 0, 1, 1, 1,
|
|
1, 1, 0, 0, 1, 0, 0, 0
|
|
};
|
|
if (no_fsrcb[fp_ins] && source_b)
|
|
goto illegal_opcode;
|
|
|
|
/* Check that none of the floating register register numbers
|
|
is higher than 15. (If this is fload, then srcA is a
|
|
general register. */
|
|
if (ins & ((1 << 14) | (1 << 8)) || (fp_ins && ins & (1 << 20)))
|
|
goto illegal_opcode;
|
|
|
|
switch (fp_ins)
|
|
{
|
|
case 0:
|
|
(*info->fprintf_func) (info->stream, "fload f%d,r%d",
|
|
indx, source_a);
|
|
break;
|
|
case 1:
|
|
(*info->fprintf_func) (info->stream, "fadd f%d,f%d,f%d",
|
|
indx, source_a, source_b);
|
|
break;
|
|
case 2:
|
|
(*info->fprintf_func) (info->stream, "fsub f%d,f%d,f%d",
|
|
indx, source_a, source_b);
|
|
break;
|
|
case 3:
|
|
(*info->fprintf_func) (info->stream, "fmult f%d,f%d,f%d",
|
|
indx, source_a, source_b);
|
|
break;
|
|
case 4:
|
|
(*info->fprintf_func) (info->stream, "fdiv f%d,f%d,f%d",
|
|
indx, source_a, source_b);
|
|
break;
|
|
case 5:
|
|
(*info->fprintf_func) (info->stream, "fsqrt f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
case 6:
|
|
(*info->fprintf_func) (info->stream, "fneg f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
case 7:
|
|
(*info->fprintf_func) (info->stream, "fabs f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
case 8:
|
|
(*info->fprintf_func) (info->stream, "ftoi f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
case 9:
|
|
(*info->fprintf_func) (info->stream, "itof f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
case 12:
|
|
(*info->fprintf_func) (info->stream, "fmove f%d,f%d",
|
|
indx, source_a);
|
|
break;
|
|
default:
|
|
(*info->fprintf_func) (info->stream,
|
|
"fpinst %d,f%d,f%d,f%d", fp_ins,
|
|
indx, source_a, source_b);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* Which EAM operations do not need a srcB register. */
|
|
const int no_srcb[32] =
|
|
{ 0, 0, 1, 1, 0, 1, 1, 1,
|
|
0, 1, 1, 1, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0
|
|
};
|
|
|
|
if (no_srcb[indx] && source_b)
|
|
goto illegal_opcode;
|
|
|
|
if (fp_ins)
|
|
goto illegal_opcode;
|
|
|
|
switch (indx)
|
|
{
|
|
case 0:
|
|
(*info->fprintf_func) (info->stream, "mults r%d,r%d",
|
|
source_a, source_b);
|
|
break;
|
|
case 1:
|
|
(*info->fprintf_func) (info->stream, "multu r%d,r%d",
|
|
source_a, source_b);
|
|
break;
|
|
case 2:
|
|
(*info->fprintf_func) (info->stream, "divs r%d",
|
|
source_a);
|
|
break;
|
|
case 3:
|
|
(*info->fprintf_func) (info->stream, "divu r%d",
|
|
source_a);
|
|
break;
|
|
case 4:
|
|
(*info->fprintf_func) (info->stream, "writemd r%d,r%d",
|
|
source_a, source_b);
|
|
break;
|
|
case 5:
|
|
(*info->fprintf_func) (info->stream, "writemdc r%d",
|
|
source_a);
|
|
break;
|
|
case 6:
|
|
(*info->fprintf_func) (info->stream, "divds r%d",
|
|
source_a);
|
|
break;
|
|
case 7:
|
|
(*info->fprintf_func) (info->stream, "divdu r%d",
|
|
source_a);
|
|
break;
|
|
case 9:
|
|
(*info->fprintf_func) (info->stream, "asrd r%d",
|
|
source_a);
|
|
break;
|
|
case 10:
|
|
(*info->fprintf_func) (info->stream, "lsrd r%d",
|
|
source_a);
|
|
break;
|
|
case 11:
|
|
(*info->fprintf_func) (info->stream, "asld r%d",
|
|
source_a);
|
|
break;
|
|
default:
|
|
(*info->fprintf_func) (info->stream,
|
|
"eamwrite %d,r%d,r%d", indx,
|
|
source_a, source_b);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* WRITE - write to memory. */
|
|
(*info->fprintf_func) (info->stream, "write.%s %d(r%d),r%d",
|
|
size_names[size], indx, source_a, source_b);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
|
|
illegal_opcode:
|
|
return -1;
|
|
}
|
|
|
|
/* Disassemble storage immediate class instructions. */
|
|
|
|
static int
|
|
disassem_class2 (disassemble_info *info, unsigned int ins)
|
|
{
|
|
int opcode = (ins >> 21) & 0xf;
|
|
int source_a = (ins >> 16) & 0x1f;
|
|
unsigned immediate = ins & 0x0000ffff;
|
|
|
|
if (ins & CC_MASK)
|
|
goto illegal_opcode;
|
|
|
|
switch (opcode)
|
|
{
|
|
case 0:
|
|
/* ADDI instruction. */
|
|
(*info->fprintf_func) (info->stream, "addi r%d,%d", source_a,
|
|
immediate);
|
|
break;
|
|
case 1:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 2:
|
|
/* SUBI instruction. */
|
|
(*info->fprintf_func) (info->stream, "subi r%d,%d", source_a,
|
|
immediate);
|
|
break;
|
|
case 3:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 4:
|
|
/* MOVIL instruction. */
|
|
(*info->fprintf_func) (info->stream, "movil r%d,0x%04X", source_a,
|
|
immediate);
|
|
break;
|
|
case 5:
|
|
/* MOVIU instruction. */
|
|
(*info->fprintf_func) (info->stream, "moviu r%d,0x%04X", source_a,
|
|
immediate);
|
|
break;
|
|
case 6:
|
|
/* MOVIQ instruction. */
|
|
(*info->fprintf_func) (info->stream, "moviq r%d,%u", source_a,
|
|
immediate);
|
|
break;
|
|
case 7:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 8:
|
|
/* WRTL instruction. */
|
|
if (source_a != 0)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "wrtl 0x%04X", immediate);
|
|
break;
|
|
case 9:
|
|
/* WRTU instruction. */
|
|
if (source_a != 0)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "wrtu 0x%04X", immediate);
|
|
break;
|
|
case 10:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 11:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 12:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 13:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 14:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
case 15:
|
|
/* Illegal opcode. */
|
|
goto illegal_opcode;
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
|
|
illegal_opcode:
|
|
return -1;
|
|
}
|
|
|
|
/* Disassemble storage register class instructions. */
|
|
|
|
static int
|
|
disassem_class3 (disassemble_info *info, unsigned int ins)
|
|
{
|
|
int opcode = (ins >> 21) & 0xf;
|
|
int source_b = (ins >> 4) & 0x1f;
|
|
int source_a = (ins >> 16) & 0x1f;
|
|
int size = ins & 0x7;
|
|
int dest = (ins >> 10) & 0x1f;
|
|
|
|
/* Those instructions that don't have a srcB register. */
|
|
const int no_srcb[16] =
|
|
{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 };
|
|
|
|
/* These are instructions which can take an immediate srcB value. */
|
|
const int srcb_immed[16] =
|
|
{ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 };
|
|
|
|
/* User opcodes should not provide a non-zero srcB register
|
|
when none is required. Only a BRA or floating point
|
|
instruction should have a non-zero condition code field.
|
|
Only a WRITE or EAMWRITE (opcode 15) should select an EAM
|
|
or floating point operation. Note that FP_SELECT_MASK is
|
|
the same bit (bit 3) as the interrupt bit which
|
|
distinguishes SYS1 from BRA and SYS2 from RFLAG. */
|
|
if ((no_srcb[opcode] && source_b)
|
|
|| (!srcb_immed[opcode] && ins & CLASS3_SOURCEB_IMMED)
|
|
|| (opcode != 12 && opcode != 15 && ins & CC_MASK)
|
|
|| (opcode != 15 && ins & (EAM_SELECT_MASK | FP_SELECT_MASK)))
|
|
goto illegal_opcode;
|
|
|
|
|
|
switch (opcode)
|
|
{
|
|
case 0:
|
|
/* ADD instruction. */
|
|
(*info->fprintf_func) (info->stream, "add.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 1:
|
|
/* ADC instruction. */
|
|
(*info->fprintf_func) (info->stream, "adc.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 2:
|
|
/* SUB instruction. */
|
|
if (dest == 0)
|
|
(*info->fprintf_func) (info->stream, "cmp.%s r%d,r%d",
|
|
size_names[size], source_a, source_b);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "sub.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 3:
|
|
/* SUBC instruction. */
|
|
if (dest == 0)
|
|
(*info->fprintf_func) (info->stream, "cmpc.%s r%d,r%d",
|
|
size_names[size], source_a, source_b);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "subc.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 4:
|
|
/* EXTW instruction. */
|
|
if (size == 1)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "extw.%s r%d,r%d",
|
|
size_names[size], dest, source_a);
|
|
break;
|
|
case 5:
|
|
/* ASR instruction. */
|
|
if (ins & CLASS3_SOURCEB_IMMED)
|
|
(*info->fprintf_func) (info->stream, "asr.%s r%d,r%d,%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "asr.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 6:
|
|
/* LSR instruction. */
|
|
if (ins & CLASS3_SOURCEB_IMMED)
|
|
(*info->fprintf_func) (info->stream, "lsr.%s r%d,r%d,%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "lsr.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 7:
|
|
/* ASL instruction. */
|
|
if (ins & CLASS3_SOURCEB_IMMED)
|
|
(*info->fprintf_func) (info->stream, "asl.%s r%d,r%d,%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "asl.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 8:
|
|
/* XOR instruction. */
|
|
(*info->fprintf_func) (info->stream, "xor.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 9:
|
|
/* OR instruction. */
|
|
if (source_b == 0)
|
|
(*info->fprintf_func) (info->stream, "move.%s r%d,r%d",
|
|
size_names[size], dest, source_a);
|
|
else
|
|
(*info->fprintf_func) (info->stream, "or.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 10:
|
|
/* AND instruction. */
|
|
(*info->fprintf_func) (info->stream, "and.%s r%d,r%d,r%d",
|
|
size_names[size], dest, source_a, source_b);
|
|
break;
|
|
case 11:
|
|
/* NOT instruction. */
|
|
(*info->fprintf_func) (info->stream, "not.%s r%d,r%d",
|
|
size_names[size], dest, source_a);
|
|
break;
|
|
case 12:
|
|
/* BRA instruction. */
|
|
{
|
|
unsigned cbf = (ins >> 27) & 0x000f;
|
|
|
|
if (size != 4)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "bra %s,r%d,r%d",
|
|
cc_names[cbf], source_a, dest);
|
|
}
|
|
break;
|
|
case 13:
|
|
/* RFLAG instruction. */
|
|
if (source_a || size != 4)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "rflag r%d", dest);
|
|
break;
|
|
case 14:
|
|
/* EXTB instruction. */
|
|
(*info->fprintf_func) (info->stream, "extb.%s r%d,r%d",
|
|
size_names[size], dest, source_a);
|
|
break;
|
|
case 15:
|
|
if (!(ins & CLASS3_SOURCEB_IMMED))
|
|
goto illegal_opcode;
|
|
|
|
if (ins & EAM_SELECT_MASK)
|
|
{
|
|
/* Extension arithmetic module read. */
|
|
int fp_ins = (ins >> 27) & 0xf;
|
|
|
|
if (size != 4)
|
|
goto illegal_opcode;
|
|
|
|
if (ins & FP_SELECT_MASK)
|
|
{
|
|
/* Check fsrcA <= 15 and fsrcB <= 15. */
|
|
if (ins & ((1 << 20) | (1 << 8)))
|
|
goto illegal_opcode;
|
|
|
|
switch (fp_ins)
|
|
{
|
|
case 0:
|
|
if (source_b)
|
|
goto illegal_opcode;
|
|
|
|
(*info->fprintf_func) (info->stream, "fstore r%d,f%d",
|
|
dest, source_a);
|
|
break;
|
|
case 10:
|
|
(*info->fprintf_func) (info->stream, "fcmp r%d,f%d,f%d",
|
|
dest, source_a, source_b);
|
|
break;
|
|
case 11:
|
|
(*info->fprintf_func) (info->stream, "fcmpe r%d,f%d,f%d",
|
|
dest, source_a, source_b);
|
|
break;
|
|
default:
|
|
(*info->fprintf_func) (info->stream,
|
|
"fpuread %d,r%d,f%d,f%d", fp_ins,
|
|
dest, source_a, source_b);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (fp_ins || source_a)
|
|
goto illegal_opcode;
|
|
|
|
switch (source_b)
|
|
{
|
|
case 0:
|
|
(*info->fprintf_func) (info->stream, "readmda r%d", dest);
|
|
break;
|
|
case 1:
|
|
(*info->fprintf_func) (info->stream, "readmdb r%d", dest);
|
|
break;
|
|
case 2:
|
|
(*info->fprintf_func) (info->stream, "readmdc r%d", dest);
|
|
break;
|
|
default:
|
|
(*info->fprintf_func) (info->stream, "eamread r%d,%d",
|
|
dest, source_b);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ins & FP_SELECT_MASK)
|
|
goto illegal_opcode;
|
|
|
|
/* READ instruction. */
|
|
(*info->fprintf_func) (info->stream, "read.%s r%d,%d(r%d)",
|
|
size_names[size], dest, source_b, source_a);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
|
|
illegal_opcode:
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Print the visium instruction at address addr in debugged memory,
|
|
on info->stream. Return length of the instruction, in bytes. */
|
|
|
|
int
|
|
print_insn_visium (bfd_vma addr, disassemble_info *info)
|
|
{
|
|
unsigned ins;
|
|
unsigned p1, p2;
|
|
int ans;
|
|
int i;
|
|
|
|
/* Stuff copied from m68k-dis.c. */
|
|
struct private priv;
|
|
bfd_byte *buffer = priv.the_buffer;
|
|
info->private_data = (PTR) & priv;
|
|
priv.max_fetched = priv.the_buffer;
|
|
priv.insn_start = addr;
|
|
if (setjmp (priv.bailout) != 0)
|
|
{
|
|
/* Error return. */
|
|
return -1;
|
|
}
|
|
|
|
/* We do return this info. */
|
|
info->insn_info_valid = 1;
|
|
|
|
/* Assume non branch insn. */
|
|
info->insn_type = dis_nonbranch;
|
|
|
|
/* Assume no delay. */
|
|
info->branch_delay_insns = 0;
|
|
|
|
/* Assume no target known. */
|
|
info->target = 0;
|
|
|
|
/* Get 32-bit instruction word. */
|
|
FETCH_DATA (info, buffer + 4);
|
|
ins = (unsigned) buffer[0] << 24;
|
|
ins |= buffer[1] << 16;
|
|
ins |= buffer[2] << 8;
|
|
ins |= buffer[3];
|
|
|
|
ans = 0;
|
|
|
|
p1 = buffer[0] ^ buffer[1] ^ buffer[2] ^ buffer[3];
|
|
p2 = 0;
|
|
for (i = 0; i < 8; i++)
|
|
{
|
|
p2 += p1 & 1;
|
|
p1 >>= 1;
|
|
}
|
|
|
|
/* Decode the instruction. */
|
|
if (p2 & 1)
|
|
ans = -1;
|
|
else
|
|
{
|
|
switch ((ins >> 25) & 0x3)
|
|
{
|
|
case 0:
|
|
ans = disassem_class0 (info, ins);
|
|
break;
|
|
case 1:
|
|
ans = disassem_class1 (info, ins);
|
|
break;
|
|
case 2:
|
|
ans = disassem_class2 (info, ins);
|
|
break;
|
|
case 3:
|
|
ans = disassem_class3 (info, ins);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (ans != 0)
|
|
(*info->fprintf_func) (info->stream, "err");
|
|
|
|
/* Return number of bytes consumed (always 4 for the Visium). */
|
|
return 4;
|
|
}
|