From 48ddfb4dc1f9eac756126eaf94a627d0e57a3dc7 Mon Sep 17 00:00:00 2001 From: johanknol Date: Tue, 19 Sep 2000 13:32:39 +0000 Subject: [PATCH] fixed genUminus bug for int and long git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@382 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/ds390/gen.c | 17 +++++++++++------ src/mcs51/gen.c | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 4b0255ff..b105888b 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -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++); } diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index d26aa0c8..49dfe21a 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -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++); } -- 2.47.2