+2019-12-11 Alan Modra <amodra@gmail.com>
+
+ * ns32k-dis.c (bit_extract): Use unsigned arithmetic.
+ (bit_extract_simple, sign_extend): Likewise.
+
2019-12-11 Alan Modra <amodra@gmail.com>
* nios2-dis.c (nios2_print_insn_arg): Use 1u << 31.
static int
bit_extract (bfd_byte *buffer, int offset, int count)
{
- int result;
- int bit;
+ unsigned int result;
+ unsigned int bit;
if (offset < 0 || count < 0)
return 0;
static int
bit_extract_simple (bfd_byte *buffer, int offset, int count)
{
- int result;
- int bit;
+ unsigned int result;
+ unsigned int bit;
if (offset < 0 || count < 0)
return 0;
}
static int
-sign_extend (int value, int bits)
+sign_extend (unsigned int value, unsigned int bits)
{
- value = value & ((1 << bits) - 1);
- return (value & (1 << (bits - 1))
- ? value | (~((1 << bits) - 1))
- : value);
+ unsigned int sign = 1u << bits;
+ return ((value & (sign - 1)) ^ sign) - sign;
}
static void