From: Diego Novillo Date: Thu, 7 Oct 1999 06:26:25 +0000 (+0000) Subject: * config/tc-d30v.c (CHAR_BIT): Define. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba09cd8d9803659ee555723ef8456131ba504aaf;p=binutils-gdb.git * config/tc-d30v.c (CHAR_BIT): Define. (check_range): Fix bit operations to support integers bigger than 32 bits. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index bcfe7fa9227..fc1e18985d2 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 7 00:23:53 MDT 1999 Diego Novillo + + * 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 * 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 04ceebe872c..25c54124242 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 +#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;