mirror of
https://github.com/cc65/cc65.git
synced 2024-12-26 08:32:00 +00:00
Fixed problems with the range check on 64 bit machines.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5173 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
aaa19a569d
commit
34d393a76f
@ -405,14 +405,14 @@ unsigned SegWriteConstExpr (FILE* F, ExprNode* E, int Signed, unsigned Size)
|
||||
* check and return one of the SEG_EXPR_xxx codes.
|
||||
*/
|
||||
{
|
||||
static const unsigned long U_HighRange [4] = {
|
||||
0x000000FF, 0x0000FFFF, 0x00FFFFFF, 0xFFFFFFFF
|
||||
static const unsigned long U_Hi[4] = {
|
||||
0x000000FFUL, 0x0000FFFFUL, 0x00FFFFFFUL, 0xFFFFFFFFUL
|
||||
};
|
||||
static const long S_HighRange [4] = {
|
||||
0x0000007F, 0x00007FFF, 0x007FFFFF, 0x7FFFFFFF
|
||||
static const long S_Hi[4] = {
|
||||
0x0000007FL, 0x00007FFFL, 0x007FFFFFL, 0x7FFFFFFFL
|
||||
};
|
||||
static const long S_LowRange [4] = {
|
||||
0xFFFFFF80, 0xFFFF8000, 0xFF800000, 0x80000000
|
||||
static const long S_Lo[4] = {
|
||||
~0x0000007FL, ~0x00007FFFL, ~0x007FFFFFL, ~0x7FFFFFFFL
|
||||
};
|
||||
|
||||
|
||||
@ -424,12 +424,12 @@ unsigned SegWriteConstExpr (FILE* F, ExprNode* E, int Signed, unsigned Size)
|
||||
|
||||
/* Check for a range error */
|
||||
if (Signed) {
|
||||
if (Val > S_HighRange [Size-1] || Val < S_LowRange [Size-1]) {
|
||||
if (Val > S_Hi[Size-1] || Val < S_Lo[Size-1]) {
|
||||
/* Range error */
|
||||
return SEG_EXPR_RANGE_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (((unsigned long)Val) > U_HighRange [Size-1]) {
|
||||
if (((unsigned long)Val) > U_Hi[Size-1]) {
|
||||
/* Range error */
|
||||
return SEG_EXPR_RANGE_ERROR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user