projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update ROCm for multi-target support
[deliverable/binutils-gdb.git]
/
opcodes
/
moxie-dis.c
diff --git
a/opcodes/moxie-dis.c
b/opcodes/moxie-dis.c
index 4e67e2c5551443e140a0f5fa3a71a0ba4205e7a1..06580abe28f8fb7ca29a9220bf7928dab9c92be7 100644
(file)
--- a/
opcodes/moxie-dis.c
+++ b/
opcodes/moxie-dis.c
@@
-1,6
+1,5
@@
/* Disassemble moxie instructions.
/* Disassemble moxie instructions.
- Copyright 2009
- Free Software Foundation, Inc.
+ Copyright (C) 2009-2020 Free Software Foundation, Inc.
This file is part of the GNU opcodes library.
This file is part of the GNU opcodes library.
@@
-19,13
+18,14
@@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include <stdio.h>
#include "sysdep.h"
#include "sysdep.h"
+#include <stdio.h>
+
#define STATIC_TABLE
#define DEFINE_TABLE
#include "opcode/moxie.h"
#define STATIC_TABLE
#define DEFINE_TABLE
#include "opcode/moxie.h"
-#include "dis
-asm
.h"
+#include "dis
assemble
.h"
static fprintf_ftype fpr;
static void *stream;
static fprintf_ftype fpr;
static void *stream;
@@
-33,7
+33,7
@@
static void *stream;
/* Macros to extract operands from the instruction word. */
#define OP_A(i) ((i >> 4) & 0xf)
#define OP_B(i) (i & 0xf)
/* Macros to extract operands from the instruction word. */
#define OP_A(i) ((i >> 4) & 0xf)
#define OP_B(i) (i & 0xf)
-#define INST2OFFSET(o) ((((
signed short)((o & ((1<<10)-1))<<6))>>6)<<1
)
+#define INST2OFFSET(o) ((((
(o) & 0x3ff) ^ 0x200) - 0x200) * 2
)
static const char * reg_names[16] =
{ "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5",
static const char * reg_names[16] =
{ "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5",
@@
-52,7
+52,11
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
if ((status = info->read_memory_func (addr, buffer, 2, info)))
goto fail;
if ((status = info->read_memory_func (addr, buffer, 2, info)))
goto fail;
- iword = bfd_getb16 (buffer);
+
+ if (info->endian == BFD_ENDIAN_BIG)
+ iword = bfd_getb16 (buffer);
+ else
+ iword = bfd_getl16 (buffer);
/* Form 1 instructions have the high bit set to 0. */
if ((iword & (1<<15)) == 0)
/* Form 1 instructions have the high bit set to 0. */
if ((iword & (1<<15)) == 0)
@@
-78,7
+82,10
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb32 (buffer);
+ else
+ imm = bfd_getl32 (buffer);
fpr (stream, "%s\t%s, 0x%x", opcode->name,
reg_names[OP_A(iword)], imm);
length = 6;
fpr (stream, "%s\t%s, 0x%x", opcode->name,
reg_names[OP_A(iword)], imm);
length = 6;
@@
-89,7
+96,10
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb32 (buffer);
+ else
+ imm = bfd_getl32 (buffer);
fpr (stream, "%s\t0x%x", opcode->name, imm);
length = 6;
}
fpr (stream, "%s\t0x%x", opcode->name, imm);
length = 6;
}
@@
-99,7
+109,10
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb32 (buffer);
+ else
+ imm = bfd_getl32 (buffer);
fpr (stream, "%s\t", opcode->name);
info->print_address_func ((bfd_vma) imm, info);
length = 6;
fpr (stream, "%s\t", opcode->name);
info->print_address_func ((bfd_vma) imm, info);
length = 6;
@@
-118,41
+131,53
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
unsigned imm;
if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb32 (buffer);
+ else
+ imm = bfd_getl32 (buffer);
fpr (stream, "%s\t0x%x, %s",
opcode->name, imm, reg_names[OP_A(iword)]);
length = 6;
}
break;
fpr (stream, "%s\t0x%x, %s",
opcode->name, imm, reg_names[OP_A(iword)]);
length = 6;
}
break;
- case MOXIE_F1_AiB
4
:
+ case MOXIE_F1_AiB
2
:
{
unsigned imm;
{
unsigned imm;
- if ((status = info->read_memory_func (addr+2, buffer,
4
, info)))
+ if ((status = info->read_memory_func (addr+2, buffer,
2
, info)))
goto fail;
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb16 (buffer);
+ else
+ imm = bfd_getl16 (buffer);
fpr (stream, "%s\t0x%x(%s), %s", opcode->name,
imm,
reg_names[OP_A(iword)],
reg_names[OP_B(iword)]);
fpr (stream, "%s\t0x%x(%s), %s", opcode->name,
imm,
reg_names[OP_A(iword)],
reg_names[OP_B(iword)]);
- length =
6
;
+ length =
4
;
}
break;
}
break;
- case MOXIE_F1_ABi
4
:
+ case MOXIE_F1_ABi
2
:
{
unsigned imm;
{
unsigned imm;
- if ((status = info->read_memory_func (addr+2, buffer,
4
, info)))
+ if ((status = info->read_memory_func (addr+2, buffer,
2
, info)))
goto fail;
goto fail;
- imm = bfd_getb32 (buffer);
+ if (info->endian == BFD_ENDIAN_BIG)
+ imm = bfd_getb16 (buffer);
+ else
+ imm = bfd_getl16 (buffer);
fpr (stream, "%s\t%s, 0x%x(%s)",
opcode->name,
reg_names[OP_A(iword)],
imm,
reg_names[OP_B(iword)]);
fpr (stream, "%s\t%s, 0x%x(%s)",
opcode->name,
reg_names[OP_A(iword)],
imm,
reg_names[OP_B(iword)]);
- length =
6
;
+ length =
4
;
}
break;
}
break;
+ case MOXIE_BAD:
+ fpr (stream, "bad");
+ break;
default:
default:
- abort
();
+ abort();
}
}
else if ((iword & (1<<14)) == 0)
}
}
else if ((iword & (1<<14)) == 0)
@@
-170,6
+195,9
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
case MOXIE_F2_NARG:
fpr (stream, "%s", opcode->name);
break;
case MOXIE_F2_NARG:
fpr (stream, "%s", opcode->name);
break;
+ case MOXIE_BAD:
+ fpr (stream, "bad");
+ break;
default:
abort();
}
default:
abort();
}
@@
-182,8
+210,10
@@
print_insn_moxie (bfd_vma addr, struct disassemble_info * info)
{
case MOXIE_F3_PCREL:
fpr (stream, "%s\t", opcode->name);
{
case MOXIE_F3_PCREL:
fpr (stream, "%s\t", opcode->name);
- info->print_address_func ((bfd_vma) (addr + INST2OFFSET(iword)),
- info);
+ info->print_address_func (addr + INST2OFFSET (iword) + 2, info);
+ break;
+ case MOXIE_BAD:
+ fpr (stream, "bad");
break;
default:
abort();
break;
default:
abort();
This page took
0.0401359999999999 seconds
and
4
git commands to generate.