From: epetrich Date: Tue, 14 Oct 2003 06:40:15 +0000 (+0000) Subject: * src/z80/gen.c: fixed bug revealed by ast_constant_folding.c regression test X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=46d3d2646140226db4dafa7bbc27a1a50617f8bd;p=fw%2Fsdcc * src/z80/gen.c: fixed bug revealed by ast_constant_folding.c regression test * src/ds390/gen.c (genCast): fixed bug #821957 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2938 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 54189d67..ce61245f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-10-14 Erik Petrich + + * src/z80/gen.c: fixed bug revealed by ast_constant_folding.c + regression test + * src/ds390/gen.c (genCast): fixed bug #821957 + 2003-10-13 Bernhard Held * device/lib/logf.c: "fixed" overlay bug diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 99dba5b4..a171483f 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -11047,7 +11047,7 @@ genCast (iCode * ic) return; aopOp (right, ic, FALSE, FALSE); - aopOp (result, ic, FALSE, AOP_USESDPTR(right)); + aopOp (result, ic, FALSE, (AOP_TYPE(right) == AOP_DPTR)); /* if the result is a bit */ if (IS_BITVAR (OP_SYMBOL (result)->type) diff --git a/src/z80/gen.c b/src/z80/gen.c index e1590731..e9b3302b 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -221,6 +221,7 @@ static struct bool in_home; const char *lastFunctionName; iCode *current_iCode; + bool preserveCarry; set *sendSet; @@ -1481,6 +1482,12 @@ setupPairFromSP (PAIR_ID id, int offset) { wassertl (id == PAIR_HL, "Setup relative to SP only implemented for HL"); + if (_G.preserveCarry) + { + _push (PAIR_AF); + offset += 2; + } + if (offset < INT8MIN || offset > INT8MAX) { emit2 ("ld hl,!immedword", offset); @@ -1488,7 +1495,13 @@ setupPairFromSP (PAIR_ID id, int offset) } else { - emit2 ("!ldahlsp", offset); + emit2 ("!ldahlsp", offset); + } + + if (_G.preserveCarry) + { + _pop (PAIR_AF); + offset -= 2; } } @@ -1524,11 +1537,15 @@ setupPair (PAIR_ID pairId, asmop * aop, int offset) else { /* PENDING: Do this better. */ + if (_G.preserveCarry) + _push (PAIR_AF); sprintf (buffer, "%d", offset + _G.stack.pushed); emit2 ("ld %s,!hashedstr", _pairs[pairId].name, buffer); emit2 ("add %s,sp", _pairs[pairId].name); _G.pairs[pairId].last_type = aop->type; _G.pairs[pairId].offset = offset; + if (_G.preserveCarry) + _pop (PAIR_AF); } } break; @@ -3481,7 +3498,10 @@ setupToPreserveCarry (asmop *result, asmop *left, asmop *right) } else if (couldDestroyCarry (right)) { - shiftIntoPair (0, right); + if (getPairId (result) == PAIR_HL) + _G.preserveCarry = TRUE; + else + shiftIntoPair (0, right); } else if (couldDestroyCarry (result)) { @@ -3712,6 +3732,7 @@ genPlus (iCode * ic) } release: + _G.preserveCarry = FALSE; freeAsmop (IC_LEFT (ic), NULL, ic); freeAsmop (IC_RIGHT (ic), NULL, ic); freeAsmop (IC_RESULT (ic), NULL, ic); @@ -3915,6 +3936,7 @@ genMinus (iCode * ic) } release: + _G.preserveCarry = FALSE; freeAsmop (IC_LEFT (ic), NULL, ic); freeAsmop (IC_RIGHT (ic), NULL, ic); freeAsmop (IC_RESULT (ic), NULL, ic);