From: slade_rich Date: Tue, 28 Dec 2004 23:34:24 +0000 (+0000) Subject: Fixed problem with subtraction where the result would not be updated when borrowing. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4995e405a3d7b1041140930db465de43ad3113e5;p=fw%2Fsdcc Fixed problem with subtraction where the result would not be updated when borrowing. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3620 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/pic/genarith.c b/src/pic/genarith.c index ad58c923..37b3151c 100644 --- a/src/pic/genarith.c +++ b/src/pic/genarith.c @@ -1604,26 +1604,19 @@ void genMinus (iCode *ic) if(size){ if (pic14_sameRegs(AOP(IC_RIGHT(ic)), AOP(IC_RESULT(ic)))) { + int lit = 0; if ((AOP_TYPE(IC_LEFT(ic)) == AOP_PCODE) && ( (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_LITERAL) || (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_IMMEDIATE))) { - while(size--){ - emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset)); - emitSKPC; - emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset)); - emitpcode(POC_SUBLW, popGet(AOP(IC_LEFT(ic)),offset)); - emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset)); - offset++; - } - } else { - while(size--){ - emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset)); - emitSKPC; - emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset)); - emitpcode(POC_SUBFW, popGet(AOP(IC_LEFT(ic)),offset)); - emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset)); - offset++; - } + lit = 1; + } + while(size--){ + emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset)); + emitSKPC; + emitpcode(POC_INCFW, popGet(AOP(IC_RIGHT(ic)),offset)); + emitpcode(lit?POC_SUBLW:POC_SUBFW, popGet(AOP(IC_LEFT(ic)),offset)); + emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset)); + offset++; } } else { PIC_OPCODE poc = POC_MOVFW;