/* alpha-dis.c -- Disassemble Alpha AXP instructions
- Copyright 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@tamu.edu>,
patterned after the PPC opcode handling written by Ian Lance Taylor.
/* OSF register names. */
-static const char * const osf_regnames[64] =
-{
+static const char * const osf_regnames[64] = {
"v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
"t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp",
"a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
/* VMS register names. */
-static const char * const vms_regnames[64] =
-{
+static const char * const vms_regnames[64] = {
"R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
"R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15",
"R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23",
opcode_end = opcode + alpha_num_opcodes;
for (op = 0; op < AXP_NOPS; ++op)
- {
- opcode_index[op] = opcode;
- while (opcode < opcode_end && op == AXP_OP (opcode->opcode))
+ {
+ opcode_index[op] = opcode;
+ while (opcode < opcode_end && op == AXP_OP (opcode->opcode))
++opcode;
- }
+ }
opcode_index[op] = opcode;
}
int status = (*info->read_memory_func) (memaddr, buffer, 4, info);
if (status != 0)
{
- (*info->memory_error_func) (status, memaddr, info);
- return -1;
+ (*info->memory_error_func) (status, memaddr, info);
+ return -1;
}
insn = bfd_getl32 (buffer);
}
op = AXP_OP (insn);
/* Find the first match in the opcode table. */
- opcode_end = opcode_index[op+1];
+ opcode_end = opcode_index[op + 1];
for (opcode = opcode_index[op]; opcode < opcode_end; ++opcode)
{
if ((insn & opcode->mask) != opcode->opcode)
have extraction functions, and, if they do, make sure the
instruction is valid. */
{
- int invalid = 0;
- for (opindex = opcode->operands; *opindex != 0; opindex++)
+ int invalid = 0;
+ for (opindex = opcode->operands; *opindex != 0; opindex++)
{
- const struct alpha_operand *operand = alpha_operands + *opindex;
+ const struct alpha_operand *operand = alpha_operands + *opindex;
if (operand->extract)
(*operand->extract) (insn, &invalid);
}
- if (invalid)
+ if (invalid)
continue;
}
/* No instruction found */
(*info->fprintf_func) (info->stream, ".long %#08x", insn);
-
+
return 4;
found:
}
if (need_comma &&
- ((operand->flags & (AXP_OPERAND_PARENS|AXP_OPERAND_COMMA))
+ ((operand->flags & (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA))
!= AXP_OPERAND_PARENS))
{
(*info->fprintf_func) (info->stream, ",");
if (operand->flags & AXP_OPERAND_IR)
(*info->fprintf_func) (info->stream, "%s", regnames[value]);
else if (operand->flags & AXP_OPERAND_FPR)
- (*info->fprintf_func) (info->stream, "%s", regnames[value+32]);
+ (*info->fprintf_func) (info->stream, "%s", regnames[value + 32]);
else if (operand->flags & AXP_OPERAND_RELATIVE)
(*info->print_address_func) (memaddr + 4 + value, info);
else if (operand->flags & AXP_OPERAND_SIGNED)
/* Disassemble MN10300 instructions.
- Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdio.h>
#include "sysdep.h"
-#include "opcode/mn10300.h"
+#include "opcode/mn10300.h"
#include "dis-asm.h"
#include "opintl.h"
#define HAVE_AM33 (info->mach == AM33)
#define HAVE_AM30 (info->mach == AM30)
-int
+int
print_insn_mn10300 (memaddr, info)
bfd_vma memaddr;
struct disassemble_info *info;
if (status != 0)
{
(*info->memory_error_func) (status, memaddr, info);
- return -1;
+ return -1;
}
insn = bfd_getb16 (buffer);
consume = 2;
/* These are three byte insns. */
else if ((insn & 0xff) == 0xf8
- || (insn & 0xff) == 0xcc
+ || (insn & 0xff) == 0xcc
|| (insn & 0xff) == 0xf9
|| (insn & 0xf3) == 0x01
|| (insn & 0xf3) == 0x02
(*info->memory_error_func) (status, memaddr, info);
return -1;
}
- insn |= *(unsigned char *)buffer;
+ insn |= *(unsigned char *) buffer;
consume = 3;
}
mysize = 7;
else
mysize = 7;
-
+
if ((op->mask & insn) == op->opcode
&& size == (unsigned int) mysize
&& (op->machine == 0
const unsigned char *opindex_ptr;
unsigned int nocomma;
int paren = 0;
-
+
if (op->format == FMT_D1 || op->format == FMT_S1)
extra_shift = 8;
else if (op->format == FMT_D2 || op->format == FMT_D4
(*info->memory_error_func) (status, memaddr, info);
return;
}
- extension = *(unsigned char *)buffer;
+ extension = *(unsigned char *) buffer;
}
else if (size == 6 && op->format == FMT_D8)
{
(*info->memory_error_func) (status, memaddr, info);
return;
}
- insn |= *(unsigned char *)buffer;
+ insn |= *(unsigned char *) buffer;
status = (*info->read_memory_func) (memaddr + 3, buffer, 2, info);
if (status != 0)
insn &= 0xff000000;
insn |= (temp >> 8) & 0xffffff;
extension = (temp & 0xff) << 16;
-
+
status = (*info->read_memory_func) (memaddr + 5, buffer, 2, info);
if (status != 0)
{
insn &= 0xffff0000;
insn |= (temp >> 16) & 0xffff;
extension = (temp & 0xffff) << 8;
-
+
status = (*info->read_memory_func) (memaddr + 6, buffer, 1, info);
if (status != 0)
{
(*info->memory_error_func) (status, memaddr, info);
return;
}
- extension |= *(unsigned char *)buffer;
+ extension |= *(unsigned char *) buffer;
}
match = 1;
temp = extension >> operand->shift;
temp &= ((1 << (32 - operand->bits)) - 1);
value |= temp;
- value = ((value ^ (((unsigned long)1) << 31))
- - (((unsigned long)1) << 31));
+ value = ((value ^ (((unsigned long) 1) << 31))
+ - (((unsigned long) 1) << 31));
}
else if ((operand->flags & MN10300_OPERAND_24BIT) != 0)
{
if ((operand->flags & MN10300_OPERAND_SIGNED) != 0
/* These are properly extended by the code above. */
&& ((operand->flags & MN10300_OPERAND_24BIT) == 0))
- value = ((value ^ (((unsigned long)1) << (operand->bits - 1)))
- - (((unsigned long)1) << (operand->bits - 1)));
+ value = ((value ^ (((unsigned long) 1) << (operand->bits - 1)))
+ - (((unsigned long) 1) << (operand->bits - 1)));
if (!nocomma
&& (!paren
(*info->fprintf_func) (info->stream, ",");
nocomma = 0;
-
+
if ((operand->flags & MN10300_OPERAND_DREG) != 0)
{
value = ((insn >> (operand->shift + extra_shift))
& ((1 << operand->bits) - 1));
- (*info->fprintf_func) (info->stream, "d%d", (int)value);
+ (*info->fprintf_func) (info->stream, "d%d", (int) value);
}
else if ((operand->flags & MN10300_OPERAND_AREG) != 0)
{
value = ((insn >> (operand->shift + extra_shift))
& ((1 << operand->bits) - 1));
- (*info->fprintf_func) (info->stream, "a%d", (int)value);
+ (*info->fprintf_func) (info->stream, "a%d", (int) value);
}
else if ((operand->flags & MN10300_OPERAND_SP) != 0)
value = ((insn >> (operand->shift + extra_shift))
& ((1 << operand->bits) - 1));
if (value < 8)
- (*info->fprintf_func) (info->stream, "r%d", (int)value);
+ (*info->fprintf_func) (info->stream, "r%d", (int) value);
else if (value < 12)
- (*info->fprintf_func) (info->stream, "a%d", (int)value - 8);
+ (*info->fprintf_func) (info->stream, "a%d", (int) value - 8);
else
- (*info->fprintf_func) (info->stream, "d%d", (int)value - 12);
+ (*info->fprintf_func) (info->stream, "d%d", (int) value - 12);
}
else if ((operand->flags & MN10300_OPERAND_XRREG) != 0)
if (value == 0)
(*info->fprintf_func) (info->stream, "sp", value);
else
- (*info->fprintf_func) (info->stream, "xr%d", (int)value);
+ (*info->fprintf_func) (info->stream, "xr%d", (int) value);
}
else if ((operand->flags & MN10300_OPERAND_USP) != 0)
(*info->fprintf_func) (info->stream, "]");
}
- else
- (*info->fprintf_func) (info->stream, "%ld", (long)value);
+ else
+ (*info->fprintf_func) (info->stream, "%ld", (long) value);
}
/* All done. */
break;
static int sprint_cc2 (disassemble_info *,char *,unsigned short);
int
-print_insn_tic54x(memaddr, info)
+print_insn_tic54x (memaddr, info)
bfd_vma memaddr;
disassemble_info *info;
{
status = (*info->read_memory_func) (memaddr, opbuf, 2, info);
if (status != 0)
{
- (*info->memory_error_func)(status, memaddr, info);
+ (*info->memory_error_func) (status, memaddr, info);
return -1;
}
- opcode = bfd_getl16(opbuf);
+ opcode = bfd_getl16 (opbuf);
if (!get_instruction (info, memaddr, opcode, &insn))
return -1;
else
{
if (!print_instruction (info, memaddr, opcode,
- (char *)insn.tm->name,
+ (char *) insn.tm->name,
insn.tm->operand_types,
size, (insn.tm->flags & FL_EXT)))
return -1;
}
- return size*2;
+ return size * 2;
}
static int
-has_lkaddr(opcode, tm)
+has_lkaddr (opcode, tm)
unsigned short opcode;
template *tm;
{
- return IS_LKADDR(opcode) &&
- (OPTYPE(tm->operand_types[0]) == OP_Smem ||
- OPTYPE(tm->operand_types[1]) == OP_Smem ||
- OPTYPE(tm->operand_types[2]) == OP_Smem ||
- OPTYPE(tm->operand_types[1]) == OP_Sind);
+ return (IS_LKADDR (opcode)
+ && (OPTYPE (tm->operand_types[0]) == OP_Smem
+ || OPTYPE (tm->operand_types[1]) == OP_Smem
+ || OPTYPE (tm->operand_types[2]) == OP_Smem
+ || OPTYPE (tm->operand_types[1]) == OP_Sind));
}
/* always returns 1 (whether an insn template was found) since we provide an
partemplate * ptm;
insn->parallel = 0;
- for (tm = (template *)tic54x_optab; tm->name; tm++)
+ for (tm = (template *) tic54x_optab; tm->name; tm++)
{
if (tm->opcode == (opcode & tm->mask))
{
/* if lk addressing is used, the second half of the opcode gets
pushed one word later */
bfd_byte opbuf[2];
- bfd_vma addr2 = addr + 1 + has_lkaddr(opcode, tm);
- int status = (*info->read_memory_func)(addr2, opbuf, 2, info);
+ bfd_vma addr2 = addr + 1 + has_lkaddr (opcode, tm);
+ int status = (*info->read_memory_func) (addr2, opbuf, 2, info);
if (status == 0)
{
- unsigned short opcode2 = bfd_getl16(opbuf);
+ unsigned short opcode2 = bfd_getl16 (opbuf);
if (tm->opcode2 == (opcode2 & tm->mask2))
{
insn->tm = tm;
}
}
}
- for (ptm = (partemplate *)tic54x_paroptab; ptm->name; ptm++)
+ for (ptm = (partemplate *) tic54x_paroptab; ptm->name; ptm++)
{
if (ptm->opcode == (opcode & ptm->mask))
{
}
}
- insn->tm = (template *)&tic54x_unknown_opcode;
+ insn->tm = (template *) &tic54x_unknown_opcode;
return 1;
}
}
else
{
- size = insn->tm->words + has_lkaddr(opcode, insn->tm);
+ size = insn->tm->words + has_lkaddr (opcode, insn->tm);
}
return size;
if (size > 1)
{
- int status = (*info->read_memory_func) (memaddr+1, buf, 2, info);
+ int status = (*info->read_memory_func) (memaddr + 1, buf, 2, info);
if (status != 0)
return 0;
- lkaddr = opcode2 = bfd_getl16(buf);
+ lkaddr = opcode2 = bfd_getl16 (buf);
if (size > 2)
{
- status = (*info->read_memory_func) (memaddr+2, buf, 2, info);
+ status = (*info->read_memory_func) (memaddr + 2, buf, 2, info);
if (status != 0)
return 0;
- opcode2 = bfd_getl16(buf);
+ opcode2 = bfd_getl16 (buf);
}
}
- for (i=0;i < MAX_OPERANDS && OPTYPE(tm_operands[i]) != OP_None;i++)
+ for (i = 0; i < MAX_OPERANDS && OPTYPE (tm_operands[i]) != OP_None; i++)
{
char *next_comma = ",";
int optional = (tm_operands[i] & OPT) != 0;
- switch (OPTYPE(tm_operands[i]))
+ switch (OPTYPE (tm_operands[i]))
{
case OP_Xmem:
- sprint_dual_address (info, operand[i], XMEM(opcode));
+ sprint_dual_address (info, operand[i], XMEM (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_Ymem:
- sprint_dual_address (info, operand[i], YMEM(opcode));
+ sprint_dual_address (info, operand[i], YMEM (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_Smem:
case OP_Sind:
case OP_Lmem:
info->fprintf_func (info->stream, "%s", comma);
- if (INDIRECT(opcode))
+ if (INDIRECT (opcode))
{
- if (MOD(opcode) >= 12)
+ if (MOD (opcode) >= 12)
{
bfd_vma addr = lkaddr;
- int arf = ARF(opcode);
- int mod = MOD(opcode);
+ int arf = ARF (opcode);
+ int mod = MOD (opcode);
if (mod == 15)
info->fprintf_func (info->stream, "*(");
else
info->fprintf_func (info->stream, "*%sar%d(",
(mod == 13 || mod == 14 ? "+" : ""),
arf);
- (*(info->print_address_func))((bfd_vma)addr, info);
+ (*(info->print_address_func)) ((bfd_vma) addr, info);
info->fprintf_func (info->stream, ")%s",
mod == 14 ? "%" : "");
}
break;
case OP_dmad:
info->fprintf_func (info->stream, "%s", comma);
- (*(info->print_address_func))((bfd_vma)opcode2, info);
+ (*(info->print_address_func)) ((bfd_vma) opcode2, info);
break;
case OP_xpmad:
/* upper 7 bits of address are in the opcode */
- opcode2 += ((unsigned long)opcode & 0x7F) << 16;
+ opcode2 += ((unsigned long) opcode & 0x7F) << 16;
/* fall through */
case OP_pmad:
info->fprintf_func (info->stream, "%s", comma);
- (*(info->print_address_func))((bfd_vma)opcode2, info);
+ (*(info->print_address_func)) ((bfd_vma) opcode2, info);
break;
case OP_MMRX:
- sprint_mmr (info, operand[i], MMRX(opcode));
+ sprint_mmr (info, operand[i], MMRX (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_MMRY:
- sprint_mmr (info, operand[i], MMRY(opcode));
+ sprint_mmr (info, operand[i], MMRY (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_MMR:
- sprint_mmr (info, operand[i], MMR(opcode));
+ sprint_mmr (info, operand[i], MMR (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_PA:
- sprintf (operand[i], "pa%d", (unsigned)opcode2);
+ sprintf (operand[i], "pa%d", (unsigned) opcode2);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_SRC:
- src = SRC(ext ? opcode2 : opcode) ? OP_B : OP_A;
+ src = SRC (ext ? opcode2 : opcode) ? OP_B : OP_A;
sprintf (operand[i], (src == OP_B) ? "b" : "a");
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_SRC1:
- src = SRC1(ext ? opcode2 : opcode) ? OP_B : OP_A;
+ src = SRC1 (ext ? opcode2 : opcode) ? OP_B : OP_A;
sprintf (operand[i], (src == OP_B) ? "b" : "a");
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_RND:
- dst = DST(opcode) ? OP_B : OP_A;
+ dst = DST (opcode) ? OP_B : OP_A;
sprintf (operand[i], (dst == OP_B) ? "a" : "b");
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_DST:
- dst = DST(ext ? opcode2 : opcode) ? OP_B : OP_A;
+ dst = DST (ext ? opcode2 : opcode) ? OP_B : OP_A;
if (!optional || dst != src)
{
sprintf (operand[i], (dst == OP_B) ? "b" : "a");
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_ARX:
- sprintf (operand[i],"ar%d", (int)ARX(opcode));
+ sprintf (operand[i], "ar%d", (int) ARX (opcode));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_SHIFT:
- shift = SHIFT(ext ? opcode2 : opcode);
+ shift = SHIFT (ext ? opcode2 : opcode);
if (!optional || shift != 0)
{
- sprintf (operand[i],"%d", shift);
+ sprintf (operand[i], "%d", shift);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
}
else
next_comma = comma;
break;
case OP_SHFT:
- shift = SHFT(opcode);
+ shift = SHFT (opcode);
if (!optional || shift != 0)
{
- sprintf (operand[i],"%d", (unsigned)shift);
+ sprintf (operand[i], "%d", (unsigned) shift);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
}
else
next_comma = comma;
break;
case OP_lk:
- sprintf (operand[i],"#%d", (int)(short)opcode2);
+ sprintf (operand[i], "#%d", (int) (short) opcode2);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_T:
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_k8:
- sprintf (operand[i], "%d", (int)((signed char)(opcode & 0xFF)));
+ sprintf (operand[i], "%d", (int) ((signed char) (opcode & 0xFF)));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_16:
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_BITC:
- sprintf (operand[i], "%d", (int)(opcode & 0xF));
+ sprintf (operand[i], "%d", (int) (opcode & 0xF));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_CC:
case OP_CC3:
{
const char *code[] = { "eq", "lt", "gt", "neq" };
- sprintf (operand[i], code[CC3(opcode)]);
+ sprintf (operand[i], code[CC3 (opcode)]);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
}
case OP_123:
{
- int code = (opcode>>8) & 0x3;
+ int code = (opcode >> 8) & 0x3;
sprintf (operand[i], "%d", (code == 0) ? 1 : (code == 2) ? 2 : 3);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
}
case OP_k5:
sprintf (operand[i], "#%d",
- (int)(((signed char)opcode & 0x1F) << 3)>>3);
+ (int) (((signed char) opcode & 0x1F) << 3) >> 3);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_k8u:
- sprintf (operand[i], "#%d", (unsigned)(opcode & 0xFF));
+ sprintf (operand[i], "#%d", (unsigned) (opcode & 0xFF));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_k3:
- sprintf (operand[i], "#%d", (int)(opcode & 0x7));
+ sprintf (operand[i], "#%d", (int) (opcode & 0x7));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_lku:
- sprintf (operand[i], "#%d", (unsigned)opcode2);
+ sprintf (operand[i], "#%d", (unsigned) opcode2);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_N:
"intm", "hm", "xf", "cpl", "braf"
};
sprintf (operand[i], "%s",
- n ? status1[SBIT(opcode)] : status0[SBIT(opcode)]);
+ n ? status1[SBIT (opcode)] : status0[SBIT (opcode)]);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
}
case OP_12:
- sprintf (operand[i], "%d", (int)((opcode >> 9)&1) + 1);
+ sprintf (operand[i], "%d", (int) ((opcode >> 9) & 1) + 1);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_TRN:
break;
case OP_k9:
/* FIXME-- this is DP, print the original address? */
- sprintf (operand[i], "#%d", (int)(opcode & 0x1FF));
+ sprintf (operand[i], "#%d", (int) (opcode & 0x1FF));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_ARP:
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
case OP_031:
- sprintf (operand[i], "%d", (int)(opcode & 0x1F));
+ sprintf (operand[i], "%d", (int) (opcode & 0x1F));
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
default:
"*ar%d+",
"*ar%d+0%%",
};
- return sprintf (buf, formats[XMOD(code)], XARX(code));
+ return sprintf (buf, formats[XMOD (code)], XARX (code));
}
static int
"*ar%d+%%",
"*ar%d+0%%",
};
- return sprintf (buf, formats[MOD(opcode)], ARF(opcode));
+ return sprintf (buf, formats[MOD (opcode)], ARF (opcode));
}
static int
unsigned short opcode;
{
/* FIXME -- look up relocation if available */
- return sprintf (buf, "0x??%02x", (int)(opcode & 0x7F));
+ return sprintf (buf, "0x??%02x", (int) (opcode & 0x7F));
}
static int
char buf[];
int mmr;
{
- symbol *reg = (symbol *)mmregs;
+ symbol *reg = (symbol *) mmregs;
while (reg->name != NULL)
{
if (mmr == reg->value)
{
- sprintf (buf, "%s", (reg+1)->name);
+ sprintf (buf, "%s", (reg + 1)->name);
return 1;
}
++reg;
{
char acc = (opcode & 0x8) ? 'b' : 'a';
if (opcode & 0x7)
- buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode&0x7)],
- (opcode&0x20) ? ", " : "");
+ buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode & 0x7)],
+ (opcode & 0x20) ? ", " : "");
if (opcode & 0x20)
- buf += sprintf (buf, "%c%s", acc, (opcode&0x10) ? "ov" : "nov");
+ buf += sprintf (buf, "%c%s", acc, (opcode & 0x10) ? "ov" : "nov");
}
else if (opcode & 0x3F)
{