fixed genUminus bug for int and long
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 19 Sep 2000 13:32:39 +0000 (13:32 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 19 Sep 2000 13:32:39 +0000 (13:32 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@382 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/ds390/gen.c
src/mcs51/gen.c

index 4b0255ffce7cb764c0581975008083e82008b374..b105888b5d6ef8bccf019faf8c00f9fe50d156a0 100644 (file)
@@ -98,7 +98,8 @@ static void saverbank (int, iCode *,bool);
                  } \
                  free(_mova_tmp); \
                 }
-#define CLRC    emitcode("clr","c");
+#define CLRC    emitcode("clr","c")
+#define SETC    emitcode("setb","c")
 
 static lineNode *lineHead = NULL;
 static lineNode *lineCurr = NULL;
@@ -1464,15 +1465,19 @@ static void genUminus (iCode *ic)
     /* otherwise subtract from zero */
     size = AOP_SIZE(IC_LEFT(ic));
     offset = 0 ;
-    CLRC ;
+    //CLRC ;
     while(size--) {
         char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE);
         if (!strcmp(l,"a")) {
-            emitcode("cpl","a");
-            emitcode("inc","a");
+         if (offset==0)
+           SETC;
+         emitcode("cpl","a");
+         emitcode("addc", "a,#0");
         } else {
-            emitcode("clr","a");
-            emitcode("subb","a,%s",l);
+         if (offset==0)
+           CLRC;
+         emitcode("clr","a");
+         emitcode("subb","a,%s",l);
         }       
         aopPut(AOP(IC_RESULT(ic)),"a",offset++);
     }
index d26aa0c832776a3b264e5fea5372bb00188dfb2d..49dfe21a6c23d867871d1651771ac9a1d4ddcc80 100644 (file)
@@ -91,7 +91,8 @@ static void saverbank (int, iCode *,bool);
                          IC_RESULT(x)->aop->type == AOP_STK )
 
 #define MOVA(x) if (strcmp(x,"a") && strcmp(x,"acc")) emitcode("mov","a,%s",x);
-#define CLRC    emitcode("clr","c");
+#define CLRC    emitcode("clr","c")
+#define SETC    emitcode("setb","c")
 
 static lineNode *lineHead = NULL;
 static lineNode *lineCurr = NULL;
@@ -1368,15 +1369,19 @@ static void genUminus (iCode *ic)
     /* otherwise subtract from zero */
     size = AOP_SIZE(IC_LEFT(ic));
     offset = 0 ;
-    CLRC ;
+    //CLRC ;
     while(size--) {
         char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE);
         if (!strcmp(l,"a")) {
-            emitcode("cpl","a");
-            emitcode("inc","a");
+         if (offset==0)
+           SETC;
+         emitcode("cpl","a");
+         emitcode("addc","a,#0");
         } else {
-            emitcode("clr","a");
-            emitcode("subb","a,%s",l);
+         if (offset==0)
+           CLRC;
+         emitcode("clr","a");
+         emitcode("subb","a,%s",l);
         }       
         aopPut(AOP(IC_RESULT(ic)),"a",offset++);
     }