aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>1999-10-07 06:26:25 +0000
committerDiego Novillo <dnovillo@google.com>1999-10-07 06:26:25 +0000
commitba09cd8d9803659ee555723ef8456131ba504aaf (patch)
treee8067e6d497ad6c7909c40bc964c264e5ef0a4f1 /gas
parentdd04745b740947b822d14c822603d9bce80dd6bf (diff)
downloadgdb-ba09cd8d9803659ee555723ef8456131ba504aaf.zip
gdb-ba09cd8d9803659ee555723ef8456131ba504aaf.tar.gz
gdb-ba09cd8d9803659ee555723ef8456131ba504aaf.tar.bz2
* config/tc-d30v.c (CHAR_BIT): Define.
(check_range): Fix bit operations to support integers bigger than 32 bits.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-d30v.c24
2 files changed, 25 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index bcfe7fa..fc1e189 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+Thu Oct 7 00:23:53 MDT 1999 Diego Novillo <dnovillo@cygnus.com>
+
+ * config/tc-d30v.c (CHAR_BIT): Define.
+ (check_range): Fix bit operations to support integers bigger than
+ 32 bits.
+
Thu Oct 7 00:11:50 MDT 1999 Diego Novillo <dnovillo@cygnus.com>
* config/tc-d10v.c (check_range): Check range for RESTRICTED_NUM3
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index 04ceebe..25c54124 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -31,6 +31,14 @@ const char *md_shortopts = "OnNcC";
const char EXP_CHARS[] = "eE";
const char FLT_CHARS[] = "dD";
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
#define NOP_MULTIPLY 1
#define NOP_ALL 2
static int warn_nops = 0;
@@ -236,29 +244,35 @@ check_range (num, bits, flags)
int retval=0;
/* don't bother checking 32-bit values */
- if (bits == 32)
+ if (bits == 32 && sizeof(unsigned long) * CHAR_BIT == 32)
return 0;
+ /* Sign extend signed values to unsigned long */
+ if ((flags & OPERAND_SIGNED) && (num & ((unsigned long)1 << (bits - 1))))
+ num |= ((long)-1 << (bits - 1));
+
if (flags & OPERAND_SHIFT)
{
/* We know that all shifts are right by three bits.... */
if (flags & OPERAND_SIGNED)
- num = (unsigned long) (((/*signed*/ long) num) >> 3);
+ num = (unsigned long) ( (long) num >= 0)
+ ? ( ((long) num) >> 3 )
+ : ( (num >> 3) | ((unsigned long)-1 << (32 - 3)) );
else
num >>= 3;
}
if (flags & OPERAND_SIGNED)
{
- max = (1 << (bits - 1))-1;
- min = - (1 << (bits - 1));
+ max = ((unsigned long)1 << (bits - 1)) - 1;
+ min = - ((unsigned long)1 << (bits - 1));
if (((long)num > max) || ((long)num < min))
retval = 1;
}
else
{
- max = (1 << bits) - 1;
+ max = ((unsigned long)1 << bits) - 1;
min = 0;
if ((num > max) || (num < min))
retval = 1;