* src/pic16/device.c (checkAddSym): NEW, adds a symbol to set while
[fw/sdcc] / src / SDCCicode.c
index e65e7d5de73728ddbaf8bc75bd73b3a0d221f496..5c875c1a182ea55549b978a385537a60b4f43a63 100644 (file)
@@ -1219,22 +1219,32 @@ operandOperation (operand * left, operand * right,
                                 (TYPE_UDWORD) operandLitValue (right));
       break;
     case EQ_OP:
-      /* this op doesn't care about signedness */
-      {
-       TYPE_UDWORD l, r;
-
-       l = (TYPE_UDWORD) operandLitValue (left);
-       if (IS_CHAR(OP_VALUE(left)->type))
-         l &= 0xff;
-       else if (!IS_LONG (OP_VALUE(left)->type))
-         l &= 0xffff;
-       r = (TYPE_UDWORD) operandLitValue (right);
-       if (IS_CHAR(OP_VALUE(right)->type))
-         r &= 0xff;
-       else if (!IS_LONG (OP_VALUE(right)->type))
-         r &= 0xffff;
-       retval = operandFromLit (l == r);
-      }
+      if (IS_FLOAT (let) ||
+          IS_FLOAT (ret))
+       {
+         retval = operandFromLit (operandLitValue (left) ==
+                                  operandLitValue (right));
+       }
+      else
+       {
+         /* this op doesn't care about signedness */
+         TYPE_UDWORD l, r;
+
+         l = (TYPE_UDWORD) operandLitValue (left);
+         r = (TYPE_UDWORD) operandLitValue (right);
+         /* In order to correctly compare 'signed int' and 'unsigned int' it's
+            neccessary to strip them to 16 bit.
+            Literals are reduced to their cheapest type, therefore left and
+            right might have different types. It's neccessary to find a
+            common type: int (used for char too) or long */
+         if (!IS_LONG (let) &&
+             !IS_LONG (ret))
+           {
+             r = (TYPE_UWORD) r;
+             l = (TYPE_UWORD) l;
+           }
+         retval = operandFromLit (l == r);
+       }
       break;
     case '<':
       retval = operandFromLit (operandLitValue (left) <
@@ -1768,8 +1778,7 @@ usualBinaryConversions (operand ** op1, operand ** op2,
   bool oldOneByteOps = FALSE;
   static bool saidHello = FALSE;
   
-  if (   strcmp (port->target, "pic14") == 0
-      || strcmp (port->target, "pic16") == 0)
+  if (strcmp (port->target, "pic14") == 0)
     oldOneByteOps = TRUE;
   if (getenv ("SDCC_NEWONEBYTEOPS"))
     {
@@ -2090,9 +2099,11 @@ geniCodeMultiply (operand * left, operand * right, bool resultIsInt)
   /* code generated for 1 byte * 1 byte literal = 2 bytes result is more
      efficient in most cases than 2 bytes result = 2 bytes << literal
      if port has 1 byte muldiv */
-  if (p2 && !IS_FLOAT (letype) &&
-      !((resultIsInt) && (getSize (resType) != getSize (ltype)) &&
-       (port->support.muldiv == 1)))
+  if (p2 && !IS_FLOAT (letype)
+      && !((resultIsInt) && (getSize (resType) != getSize (ltype))
+           && (port->support.muldiv == 1))
+      && strcmp (port->target, "pic14") != 0  /* don't shift for pic */
+      && strcmp (port->target, "pic16") != 0)
     {
       if ((resultIsInt) && (getSize (resType) != getSize (ltype)))
        {