aboutsummaryrefslogtreecommitdiff
path: root/opcodes/m10300-dis.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2000-05-26 01:54:33 +0000
committerAlexandre Oliva <aoliva@redhat.com>2000-05-26 01:54:33 +0000
commitd60622826d14374d5b18ca343c4aae6627e58609 (patch)
treed590aee20608e7b1e86fa2d47861ddcfe464109a /opcodes/m10300-dis.c
parent0a44c2b16f06f5f84edf9cd3aeca67b764403fe8 (diff)
downloadgdb-d60622826d14374d5b18ca343c4aae6627e58609.zip
gdb-d60622826d14374d5b18ca343c4aae6627e58609.tar.gz
gdb-d60622826d14374d5b18ca343c4aae6627e58609.tar.bz2
* m10300-dis.c (disassemble): Don't assume 32-bit longs when
sign-extending operands.
Diffstat (limited to 'opcodes/m10300-dis.c')
-rw-r--r--opcodes/m10300-dis.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/opcodes/m10300-dis.c b/opcodes/m10300-dis.c
index 554d328..c15661a 100644
--- a/opcodes/m10300-dis.c
+++ b/opcodes/m10300-dis.c
@@ -484,6 +484,8 @@ disassemble (memaddr, info, insn, size)
temp = extension >> operand->shift;
temp &= ((1 << (32 - operand->bits)) - 1);
value |= temp;
+ value = ((value ^ (((unsigned long)1) << 31))
+ - (((unsigned long)1) << 31));
}
else if ((operand->flags & MN10300_OPERAND_24BIT) != 0)
{
@@ -494,7 +496,7 @@ disassemble (memaddr, info, insn, size)
temp &= ((1 << (24 - operand->bits)) - 1);
value |= temp;
if ((operand->flags & MN10300_OPERAND_SIGNED) != 0)
- value = ((value & 0xffffff) ^ (~0x7fffff)) + 0x800000;
+ value = ((value & 0xffffff) ^ 0x800000) - 0x800000;
}
else if ((operand->flags & MN10300_OPERAND_EXTENDED) != 0)
{
@@ -508,11 +510,10 @@ disassemble (memaddr, info, insn, size)
}
if ((operand->flags & MN10300_OPERAND_SIGNED) != 0
- /* These are properly extended by the code above. */
- && ((operand->flags & MN10300_OPERAND_24BIT) == 0)
- )
- value = ((long)(value << (32 - operand->bits))
- >> (32 - operand->bits));
+ /* 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)));
if (!nocomma
&& (!paren
@@ -525,14 +526,14 @@ disassemble (memaddr, info, insn, size)
{
value = ((insn >> (operand->shift + extra_shift))
& ((1 << operand->bits) - 1));
- (*info->fprintf_func) (info->stream, "d%d", 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", value);
+ (*info->fprintf_func) (info->stream, "a%d", (int)value);
}
else if ((operand->flags & MN10300_OPERAND_SP) != 0)
@@ -549,11 +550,11 @@ disassemble (memaddr, info, insn, size)
value = ((insn >> (operand->shift + extra_shift))
& ((1 << operand->bits) - 1));
if (value < 8)
- (*info->fprintf_func) (info->stream, "r%d", value);
+ (*info->fprintf_func) (info->stream, "r%d", (int)value);
else if (value < 12)
- (*info->fprintf_func) (info->stream, "a%d", value - 8);
+ (*info->fprintf_func) (info->stream, "a%d", (int)value - 8);
else
- (*info->fprintf_func) (info->stream, "d%d", value - 12);
+ (*info->fprintf_func) (info->stream, "d%d", (int)value - 12);
}
else if ((operand->flags & MN10300_OPERAND_XRREG) != 0)
@@ -563,7 +564,7 @@ disassemble (memaddr, info, insn, size)
if (value == 0)
(*info->fprintf_func) (info->stream, "sp", value);
else
- (*info->fprintf_func) (info->stream, "xr%d", value);
+ (*info->fprintf_func) (info->stream, "xr%d", (int)value);
}
else if ((operand->flags & MN10300_OPERAND_USP) != 0)
@@ -670,7 +671,7 @@ disassemble (memaddr, info, insn, size)
}
else
- (*info->fprintf_func) (info->stream, "%d", value);
+ (*info->fprintf_func) (info->stream, "%ld", (long)value);
}
/* All done. */
break;