From 5af1c3d620981628c604ed9a884d2c0438fc6bdd Mon Sep 17 00:00:00 2001 From: johanknol Date: Sun, 21 Oct 2001 10:52:16 +0000 Subject: [PATCH] some litteral long fixes, now 40000+40000 = 80000l instead of 14464 and #define TIMER1_RELOAD_VALUE -(2*OSCILATOR)/(32*12*BAUD) works again git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1421 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCval.c | 59 ++++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/src/SDCCval.c b/src/SDCCval.c index 3b711c54..b5685aae 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -454,27 +454,25 @@ value *constVal (char *s) /* Setup the flags first */ /* set the _long flag if 'lL' is found */ - if (strchr (s, 'l') || strchr (s, 'L')) + if (strchr (s, 'l') || strchr (s, 'L')) { + SPEC_NOUN (val->type) = V_INT; SPEC_LONG (val->type) = 1; + } if (sval<0) { // "-28u" will still be signed and negative SPEC_USIGN (val->type) = 0; - if (sval<-32768) { // check if we have to promote to long + if (sval<-128) { // check if we have to promote to int SPEC_NOUN (val->type) = V_INT; + } + if (sval<-32768) { // check if we have to promote to long int SPEC_LONG (val->type) = 1; - } else { - if (sval<-128) { // check if we have to promote to int - SPEC_NOUN (val->type) = V_INT; - } } - } else { - if (sval>0xffff) { // check if we have to promote to long + } else { // >=0 + if (sval>0xff) { // check if we have to promote to int SPEC_NOUN (val->type) = V_INT; + } + if (sval>0xffff) { // check if we have to promote to long int SPEC_LONG (val->type) = 1; - } else { - if (sval>0xff) { // check if we have to promote to int - SPEC_NOUN (val->type) = V_INT; - } } } @@ -1004,7 +1002,7 @@ valMult (value * lval, value * rval) IS_FLOAT (rval->etype) ? V_FLOAT : V_INT); SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */ SPEC_USIGN (val->type) = (SPEC_USIGN (lval->etype) & SPEC_USIGN (rval->etype)); - SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype)); + SPEC_LONG (val->type) = 1; if (IS_FLOAT (val->type)) SPEC_CVAL (val->type).v_float = floatFromVal (lval) * floatFromVal (rval); @@ -1019,15 +1017,6 @@ valMult (value * lval, value * rval) SPEC_CVAL (val->type).v_long = (long) floatFromVal (lval) * (long) floatFromVal (rval); } - else - { - if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = (unsigned) floatFromVal (lval) * - (unsigned) floatFromVal (rval); - else - SPEC_CVAL (val->type).v_int = (int) floatFromVal (lval) * - (int) floatFromVal (rval); - } } return cheapestVal(val); } @@ -1144,7 +1133,7 @@ valPlus (value * lval, value * rval) SPEC_USIGN (rval->etype) && (floatFromVal(lval)+floatFromVal(rval))>=0; - SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype)); + SPEC_LONG (val->type) = 1; if (IS_FLOAT (val->type)) SPEC_CVAL (val->type).v_float = floatFromVal (lval) + floatFromVal (rval); @@ -1159,16 +1148,6 @@ valPlus (value * lval, value * rval) SPEC_CVAL (val->type).v_long = (long) floatFromVal (lval) + (long) floatFromVal (rval); } - else - { - if (SPEC_USIGN (val->type)) { - SPEC_CVAL (val->type).v_uint = (unsigned) floatFromVal (lval) + - (unsigned) floatFromVal (rval); - } else { - SPEC_CVAL (val->type).v_int = (int) floatFromVal (lval) + - (int) floatFromVal (rval); - } - } } return cheapestVal(val); } @@ -1237,7 +1216,7 @@ valShift (value * lval, value * rval, int lr) val->type = val->etype = newIntLink (); SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */ SPEC_USIGN (val->type) = (SPEC_USIGN (lval->etype) & SPEC_USIGN (rval->etype)); - SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype)); + SPEC_LONG (val->type) = 1; if (SPEC_LONG (val->type)) { @@ -1250,18 +1229,6 @@ valShift (value * lval, value * rval, int lr) (long) floatFromVal (lval) << (long) floatFromVal (rval) : \ (long) floatFromVal (lval) >> (long) floatFromVal (rval); } - else - { - if (SPEC_USIGN (val->type)) { - SPEC_CVAL (val->type).v_uint = lr ? - (unsigned) floatFromVal (lval) << (unsigned) floatFromVal (rval) :\ - (unsigned) floatFromVal (lval) >> (unsigned) floatFromVal (rval); - } else { - SPEC_CVAL (val->type).v_int = lr ? - (int) floatFromVal (lval) << (int) floatFromVal (rval) : \ - (int) floatFromVal (lval) >> (int) floatFromVal (rval); - } - } return cheapestVal(val); } -- 2.30.2