summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2012-02-27 06:31:57 +0000
committerAlan Modra <amodra@bigpond.net.au>2012-02-27 06:31:57 +0000
commit5f68d9bce47a17a53d1a4c8f96da9c6eb4817670 (patch)
treed00c072b35ba3352ab9864a6413d23b66c5adbcc
parent6c422532a922e77a59df1b2d87247e29dd625f61 (diff)
downloadbinutils-redhat-5f68d9bce47a17a53d1a4c8f96da9c6eb4817670.tar.gz
* arc-dis.c (BITS): Don't use shifts to mask off bits.
(FIELDD): Sign extend with xor,sub.
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/arc-dis.c11
2 files changed, 10 insertions, 6 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 70d5f34543..cc0af8e420 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2012-02-27 Alan Modra <amodra@gmail.com>
+
+ * arc-dis.c (BITS): Don't use shifts to mask off bits.
+ (FIELDD): Sign extend with xor,sub.
+
2012-02-25 Walter Lee <walt@tilera.com>
* tilegx-opc.c: Handle TILEGX_OPC_LD4S_TLS and TILEGX_OPC_LD_TLS.
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index b4cc241615..ac7379d7b7 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -1,6 +1,6 @@
/* Instruction printing code for the ARC.
- Copyright 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009, 2010
- Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009,
+ 2010, 2012 Free Software Foundation, Inc.
Contributed by Doug Evans (dje@cygnus.com).
This file is part of libopcodes.
@@ -60,15 +60,14 @@ typedef enum
} a4_decoding_class;
#define BIT(word,n) ((word) & (1 << n))
-#define BITS(word,s,e) (((word) << (31 - e)) >> (s + (31 - e)))
+#define BITS(word,s,e) (((word) >> s) & ((1 << (e + 1 - s)) - 1))
#define OPCODE(word) (BITS ((word), 27, 31))
#define FIELDA(word) (BITS ((word), 21, 26))
#define FIELDB(word) (BITS ((word), 15, 20))
#define FIELDC(word) (BITS ((word), 9, 14))
-/* FIELD D is signed in all of its uses, so we make sure argument is
- treated as signed for bit shifting purposes: */
-#define FIELDD(word) (BITS (((signed int)word), 0, 8))
+/* FIELD D is signed. */
+#define FIELDD(word) ((BITS ((word), 0, 8) ^ 0x100) - 0x100)
#define PUT_NEXT_WORD_IN(a) \
do \