summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog4
-rw-r--r--opcodes/ns32k-dis.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index c1fce7f33cc..5345dfb2bf7 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,9 @@
2019-12-11 Alan Modra <amodra@gmail.com>
+ * ns32k-dis.c (sign_extend): Correct last patch.
+
+2019-12-11 Alan Modra <amodra@gmail.com>
+
* vax-dis.c (NEXTLONG): Avoid signed overflow.
2019-12-11 Alan Modra <amodra@gmail.com>
diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c
index 5e6f0964b7a..e43fff712ab 100644
--- a/opcodes/ns32k-dis.c
+++ b/opcodes/ns32k-dis.c
@@ -327,8 +327,8 @@ bit_copy (bfd_byte *buffer, int offset, int count, char *to)
static int
sign_extend (unsigned int value, unsigned int bits)
{
- unsigned int sign = 1u << bits;
- return ((value & (sign - 1)) ^ sign) - sign;
+ unsigned int sign = 1u << (bits - 1);
+ return ((value & (sign + sign - 1)) ^ sign) - sign;
}
static void