From: kvigor Date: Thu, 21 Sep 2000 21:17:41 +0000 (+0000) Subject: another possible impedance mismatch in genPlus/genMinus X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0b738414637cc040d5931d14989320e2f012dac2;p=fw%2Fsdcc another possible impedance mismatch in genPlus/genMinus git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@399 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 6edba6ff..527200a4 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -2786,6 +2786,7 @@ static void genPlus (iCode *ic) { int size, offset = 0; bool pushResult = FALSE; + int rSize; D(emitcode(";", "genPlus ");); @@ -2883,19 +2884,33 @@ static void genPlus (iCode *ic) aopOp (IC_RESULT(ic),ic,TRUE, FALSE); size = getDataSize(IC_LEFT(ic)); - + rSize = getDataSize(IC_RESULT(ic)); + /* If the pushed data is bigger than the result, * simply discard unused bytes. Icky, but works. * * Should we throw a warning here? We're losing data... */ - while (size > getDataSize(IC_RESULT(ic))) + while (size > rSize) { - emitcode(";", "discarding unused result byte."); + D(emitcode(";", "discarding unused result byte.");); emitcode("pop", "acc"); size--; offset--; } + if (size < rSize) + { + emitcode("clr", "a"); + /* Conversly, we haven't pushed enough here. + * just zero-pad, and all is well. + */ + while (size < rSize) + { + emitcode("push", "acc"); + size++; + offset++; + } + } while(size--) { @@ -3083,6 +3098,7 @@ static void genMinusBits (iCode *ic) static void genMinus (iCode *ic) { int size, offset = 0; + int rSize; unsigned long lit = 0L; bool pushResult = FALSE; @@ -3157,6 +3173,7 @@ static void genMinus (iCode *ic) aopOp (IC_RESULT(ic),ic,TRUE, FALSE); size = getDataSize(IC_LEFT(ic)); + rSize = getDataSize(IC_RESULT(ic)); /* If the pushed data is bigger than the result, * simply discard unused bytes. Icky, but works. @@ -3170,6 +3187,19 @@ static void genMinus (iCode *ic) size--; offset--; } + if (size < rSize) + { + emitcode("clr", "a"); + /* Conversly, we haven't pushed enough here. + * just zero-pad, and all is well. + */ + while (size < rSize) + { + emitcode("push", "acc"); + size++; + offset++; + } + } while(size--) {