some prelimanary floating point fixes
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 9 Nov 2001 15:40:49 +0000 (15:40 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 9 Nov 2001 15:40:49 +0000 (15:40 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1536 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCicode.c
src/SDCCval.c

index 441bedc9105bed4feccc0f20c93d5192574fbd07..b8abb0c0175172fc9243b9870a52ba1a10803d40 100644 (file)
@@ -2089,38 +2089,10 @@ decorateType (ast * tree)
              return decorateType (otree);
          }
 
-#if 0 
-         // we can't do this because of "(int & 0xff) << 3"
-
-         /* if right or left is literal then result of that type */
-         if (IS_LITERAL (RTYPE (tree)))
-           {
-
-             TTYPE (tree) = copyLinkChain (RTYPE (tree));
-             TETYPE (tree) = getSpec (TTYPE (tree));
-             SPEC_SCLS (TETYPE (tree)) = S_AUTO;
-           }
-         else
-           {
-             if (IS_LITERAL (LTYPE (tree)))
-               {
-                 TTYPE (tree) = copyLinkChain (LTYPE (tree));
-                 TETYPE (tree) = getSpec (TTYPE (tree));
-                 SPEC_SCLS (TETYPE (tree)) = S_AUTO;
-
-               }
-             else
-               {
-                 TTYPE (tree) =
-                   computeType (LTYPE (tree), RTYPE (tree));
-                 TETYPE (tree) = getSpec (TTYPE (tree));
-               }
-           }
-#else
          TTYPE (tree) =
            computeType (LTYPE (tree), RTYPE (tree));
          TETYPE (tree) = getSpec (TTYPE (tree));
-#endif
+
          LRVAL (tree) = RRVAL (tree) = 1;
          return tree;
        }
index f20805701514a3a22e6457bb8c4b9d2d1ace7f8d..4ca47ca57af6f6391f62d1fba6361d8204476f04 100644 (file)
@@ -2291,6 +2291,9 @@ geniCodeBitwise (operand * left, operand * right,
 {
   iCode *ic;
 
+  // bitwise operations must be done unsigned
+  SPEC_USIGN(resType)=1;
+
   left = geniCodeCast (resType, left, TRUE);
   right = geniCodeCast (resType, right, TRUE);
 
index 2e3448a51be3e1bb3dea543eb5affbce40251f08..c61a6c8c19af9525e8c2412ef7a9ba2692ea919d 100644 (file)
@@ -340,28 +340,28 @@ value *cheapestVal (value *val) {
     if (uval<=0xffff) {
       SPEC_LONG(val->type)=0;
       SPEC_CVAL(val->type).v_uint = uval;
-    }
-    if (uval<=0xff) {
-      SPEC_NOUN(val->type)=V_CHAR;
+      if (uval<=0xff) {
+       SPEC_NOUN(val->type)=V_CHAR;
+      }
     }
   } else { // not unsigned
     if (sval<0) {
       if (sval>=-32768) {
        SPEC_LONG(val->type)=0;
        SPEC_CVAL(val->type).v_int = sval & 0xffff;
-      }
-      if (sval>=-128) {
-       SPEC_NOUN(val->type)=V_CHAR;
-       SPEC_CVAL(val->type).v_int &= 0xff;
+       if (sval>=-128) {
+         SPEC_NOUN(val->type)=V_CHAR;
+         SPEC_CVAL(val->type).v_int &= 0xff;
+       }
       }
     } else { // sval>=0
       SPEC_USIGN(val->type)=1;
       if (sval<=65535) {
        SPEC_LONG(val->type)=0;
        SPEC_CVAL(val->type).v_int = sval;
-      }
-      if (sval<=255) {
-       SPEC_NOUN(val->type)=V_CHAR;
+       if (sval<=255) {
+         SPEC_NOUN(val->type)=V_CHAR;
+       }
       }
     }
   }
@@ -860,7 +860,7 @@ valFromType (sym_link * type)
 }
 
 /*------------------------------------------------------------------*/
-/* floatFromVal - value to unsinged integer conversion        */
+/* floatFromVal - value to double float conversion                  */
 /*------------------------------------------------------------------*/
 double 
 floatFromVal (value * val)