]> git.gag.com Git - fw/sdcc/commitdiff
* src/z80/gen.c: fixed bug revealed by ast_constant_folding.c regression test
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 14 Oct 2003 06:40:15 +0000 (06:40 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 14 Oct 2003 06:40:15 +0000 (06:40 +0000)
* 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

ChangeLog
src/ds390/gen.c
src/z80/gen.c

index 54189d6725f3483ddacd9e8780dc497c62b73d09..ce61245f101a609cd6cab1733e28fe9e0fc50e6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-14 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+       
+       * 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 <bernhard@bernhardheld.de>
 
        * device/lib/logf.c: "fixed" overlay bug
index 99dba5b475767aa9516308518a7a4564bd8d78f1..a171483f20c3518f9b925ab63ccfc55fc602ff74 100644 (file)
@@ -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)
index e159073147471e29ba0ddeb42a3fbd849b89d443..e9b3302b73642afb8922c51d0a4763b158635b14 100644 (file)
@@ -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);