aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-10-20 07:27:55 +0000
committerAndrew Cagney <cagney@redhat.com>1997-10-20 07:27:55 +0000
commit293a0876f8adcc5a15db7204f1871f8eda1d7920 (patch)
tree03bb23b61f3874299b1175788da27f0d2df4b5ce
parentfb5a2a3e39415db044b18604f0ffe0f07a9b83bf (diff)
downloadgdb-293a0876f8adcc5a15db7204f1871f8eda1d7920.zip
gdb-293a0876f8adcc5a15db7204f1871f8eda1d7920.tar.gz
gdb-293a0876f8adcc5a15db7204f1871f8eda1d7920.tar.bz2
Have single bit macros return an unsigned result. Avoids risk (and
need) of sign extending results.
-rw-r--r--sim/common/ChangeLog7
-rw-r--r--sim/common/sim-bits.h42
2 files changed, 33 insertions, 16 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index d38904b..2be05ff 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,10 @@
+Mon Oct 20 17:23:58 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-bits.h (LSBIT, MSBIT, BIT): Force result to type
+ unsigned_word.
+ (LSBIT8, LSBIT16, LSBIT32, LSBIT64, MSBIT8, MSBIT16, MSBIT32,
+ MSBIT64): Force result to unsignedN.
+
Thu Oct 16 11:38:56 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-alu.h (ALU16_BEGIN, ALU32_BEGIN, ALU64_BEGIN): Drop opening
diff --git a/sim/common/sim-bits.h b/sim/common/sim-bits.h
index 00a8842..3170c61 100644
--- a/sim/common/sim-bits.h
+++ b/sim/common/sim-bits.h
@@ -187,31 +187,31 @@
/* LS/MS Bit operations */
-#define LSBIT8(POS) ((natural8) 1 << (POS))
-#define LSBIT16(POS) ((natural16)1 << (POS))
-#define LSBIT32(POS) ((natural32)1 << (POS))
-#define LSBIT64(POS) ((natural64)1 << (POS))
+#define LSBIT8(POS) ((unsigned8) 1 << (POS))
+#define LSBIT16(POS) ((unsigned16)1 << (POS))
+#define LSBIT32(POS) ((unsigned32)1 << (POS))
+#define LSBIT64(POS) ((unsigned64)1 << (POS))
#if (WITH_TARGET_WORD_BITSIZE == 64)
#define LSBIT(POS) LSBIT64 (POS)
#else
-#define LSBIT(POS) ((POS) >= 32 \
- ? 0 \
- : (1 << ((POS) >= 32 ? 0 : (POS))))
+#define LSBIT(POS) ((unsigned32)((POS) >= 32 \
+ ? 0 \
+ : (1 << ((POS) >= 32 ? 0 : (POS)))))
#endif
-#define MSBIT8(POS) ((natural8) 1 << ( 8 - 1 - (POS)))
-#define MSBIT16(POS) ((natural16)1 << (16 - 1 - (POS)))
-#define MSBIT32(POS) ((natural32)1 << (32 - 1 - (POS)))
-#define MSBIT64(POS) ((natural64)1 << (64 - 1 - (POS)))
+#define MSBIT8(POS) ((unsigned8) 1 << ( 8 - 1 - (POS)))
+#define MSBIT16(POS) ((unsigned16)1 << (16 - 1 - (POS)))
+#define MSBIT32(POS) ((unsigned32)1 << (32 - 1 - (POS)))
+#define MSBIT64(POS) ((unsigned64)1 << (64 - 1 - (POS)))
#if (WITH_TARGET_WORD_BITSIZE == 64)
#define MSBIT(POS) MSBIT64 (POS)
#else
-#define MSBIT(POS) ((POS) < 32 \
- ? 0 \
- : (1 << ((POS) < 32 ? 0 : (64 - 1) - (POS))))
+#define MSBIT(POS) ((unsigned32)((POS) < 32 \
+ ? 0 \
+ : (1 << ((POS) < 32 ? 0 : (64 - 1) - (POS)))))
#endif
@@ -406,7 +406,7 @@ INLINE_SIM_BITS(unsigned_word) MSEXTRACTED (unsigned_word val, int start, int st
#define SHUFFLED(WORD, OLD, NEW) _SHUFFLEDn (_word, WORD, OLD, NEW)
-/* move a group of bits around */
+/* Insert a group of bits into a bit position */
INLINE_SIM_BITS(unsigned8) LSINSERTED8 (unsigned8 val, int start, int stop);
INLINE_SIM_BITS(unsigned16) LSINSERTED16 (unsigned16 val, int start, int stop);
@@ -436,9 +436,19 @@ INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int sto
+/* MOVE bits from one loc to another (combination of extract/insert) */
+
+#define MOVED8(VAL,OH,OL,NH,NL) INSERTED8 (EXTRACTED8 ((VAL), OH, OL), NH, NL)
+#define MOVED16(VAL,OH,OL,NH,NL) INSERTED16(EXTRACTED16((VAL), OH, OL), NH, NL)
+#define MOVED32(VAL,OH,OL,NH,NL) INSERTED32(EXTRACTED32((VAL), OH, OL), NH, NL)
+#define MOVED64(VAL,OH,OL,NH,NL) INSERTED64(EXTRACTED64((VAL), OH, OL), NH, NL)
+#define MOVED(VAL,OH,OL,NH,NL) INSERTED (EXTRACTED ((VAL), OH, OL), NH, NL)
+
+
+
/* Sign extend the quantity to the targets natural word size */
-#define EXTEND8(X) ((signed_word)(signed8)(X))
+#define EXTEND8(X) ((signed_word)(signed8)(X))
#define EXTEND16(X) ((signed_word)(signed16)(X))
#define EXTEND32(X) ((signed_word)(signed32)(X))
#define EXTEND64(X) ((signed_word)(signed64)(X))