From: johanknol Date: Mon, 5 Nov 2001 14:28:10 +0000 (+0000) Subject: fixed bug #477835 for the mcs port X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=9d2535f231a7a7eb46037b05c05fc8f8a91947aa;p=fw%2Fsdcc fixed bug #477835 for the mcs port git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1507 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/device/include/limits.h b/device/include/limits.h index a1fe0a77..23cbc60c 100644 --- a/device/include/limits.h +++ b/device/include/limits.h @@ -32,14 +32,14 @@ #define SCHAR_MIN CHAR_MIN #define UCHAR_MAX 0xff #define UCHAR_MIN 0 -#define SHRT_MAX CHAR_MAX -#define SHRT_MIN CHAR_MIN -#define USHRT_MAX UCHAR_MAX -#define USHRT_MIN UCHAR_MIN #define INT_MIN -32768 #define INT_MAX 32767 +#define SHRT_MAX INT_MAX +#define SHRT_MIN INT_MIN #define UINT_MAX 0xffff #define UINT_MIN 0 +#define USHRT_MAX UINT_MAX +#define USHRT_MIN UINT_MIN #define LONG_MIN -2147483648 #define LONG_MAX 2147483647 #define ULONG_MAX 0xffffffff diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 76add3aa..646faf85 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -1460,10 +1460,10 @@ saveRegisters (iCode * lic) IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT (ic)))) return; - /* find the registers in use at this time - and push them away to safety */ - rsave = bitVectCplAnd (bitVectCopy (ic->rMask), - ic->rUsed); + /* safe the registers in use at this time but skip the + ones for the result */ + rsave = bitVectCplAnd (bitVectCopy (ic->rMask), + mcs51_rUmaskForOp (IC_RESULT(ic))); ic->regsSaved = 1; if (options.useXstack) @@ -1503,10 +1503,11 @@ unsaveRegisters (iCode * ic) { int i; bitVect *rsave; - /* find the registers in use at this time - and push them away to safety */ - rsave = bitVectCplAnd (bitVectCopy (ic->rMask), - ic->rUsed); + + /* restore the registers in use at this time but skip the + ones for the result */ + rsave = bitVectCplAnd (bitVectCopy (ic->rMask), + mcs51_rUmaskForOp (IC_RESULT(ic))); if (options.useXstack) { @@ -1967,7 +1968,7 @@ genPcall (iCode * ic) sym_link *dtype; symbol *rlbl = newiTempLabel (NULL); - + D(emitcode(";", "genPCall")); /* if caller saves & we have not saved then */ if (!ic->regsSaved) saveRegisters (ic); diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index a6a34641..3c5f39db 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -1220,8 +1220,8 @@ serialRegAssign (eBBlock ** ebbs, int count) /*-----------------------------------------------------------------*/ /* rUmaskForOp :- returns register mask for an operand */ /*-----------------------------------------------------------------*/ -static bitVect * -rUmaskForOp (operand * op) +bitVect * +mcs51_rUmaskForOp (operand * op) { bitVect *rumask; symbol *sym; @@ -1261,7 +1261,7 @@ regsUsedIniCode (iCode * ic) if (ic->op == IFX) { rmask = bitVectUnion (rmask, - rUmaskForOp (IC_COND (ic))); + mcs51_rUmaskForOp (IC_COND (ic))); goto ret; } @@ -1269,7 +1269,7 @@ regsUsedIniCode (iCode * ic) if (ic->op == JUMPTABLE) { rmask = bitVectUnion (rmask, - rUmaskForOp (IC_JTCOND (ic))); + mcs51_rUmaskForOp (IC_JTCOND (ic))); goto ret; } @@ -1277,16 +1277,16 @@ regsUsedIniCode (iCode * ic) /* of all other cases */ if (IC_LEFT (ic)) rmask = bitVectUnion (rmask, - rUmaskForOp (IC_LEFT (ic))); + mcs51_rUmaskForOp (IC_LEFT (ic))); if (IC_RIGHT (ic)) rmask = bitVectUnion (rmask, - rUmaskForOp (IC_RIGHT (ic))); + mcs51_rUmaskForOp (IC_RIGHT (ic))); if (IC_RESULT (ic)) rmask = bitVectUnion (rmask, - rUmaskForOp (IC_RESULT (ic))); + mcs51_rUmaskForOp (IC_RESULT (ic))); ret: return rmask; diff --git a/src/mcs51/ralloc.h b/src/mcs51/ralloc.h index 85add418..fc8d87a9 100644 --- a/src/mcs51/ralloc.h +++ b/src/mcs51/ralloc.h @@ -58,4 +58,6 @@ extern regs regs8051[]; regs *mcs51_regWithIdx (int); +bitVect *mcs51_rUmaskForOp (operand * op); + #endif