* v850-dis.c (get_operand_value): Use unsigned arithmetic. Don't
sign extend using shifts.
+2019-12-11 Alan Modra <amodra@gmail.com>
+
+ * v850-dis.c (get_operand_value): Use unsigned arithmetic. Don't
+ sign extend using shifts.
+
2019-12-11 Alan Modra <amodra@gmail.com>
* tic6x-dis.c (tic6x_extract_32): Avoid signed overflow.
bfd_boolean noerror,
int *invalid)
{
- long value;
+ unsigned long value;
bfd_byte buffer[4];
if ((operand->flags & V850E_IMMEDIATE16)
if (operand->bits == -1)
value = (insn & operand->shift);
else
- value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
+ value = (insn >> operand->shift) & ((1ul << operand->bits) - 1);
if (operand->flags & V850_OPERAND_SIGNED)
- value = ((long)(value << (sizeof (long)*8 - operand->bits))
- >> (sizeof (long)*8 - operand->bits));
+ {
+ unsigned long sign = 1ul << (operand->bits - 1);
+ value = (value ^ sign) - sign;
+ }
}
return value;