Fixed bugs #2728224, #2728218
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Apr 2009 15:40:24 +0000 (15:40 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Apr 2009 15:40:24 +0000 (15:40 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5424 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/z80/gen.c
src/z80/peeph-z80.def
support/regression/tests/memory.c

index 94693ba9e87c4c2fded68b2638eddd859b6e0ed3..4b529afb400ec4beb044b6beb518290e9846a9f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-03 Philipp Klaus Krause <pkk AT spth.de>
+
+       * src/z80/gen.c:
+         Fixed bugs #2728224, #2728218.
+         src/z80/peeph-z80.def:
+         Workaround for bug #2728445.
+         support/regression/tests/memory.c:
+         Added test for memcmp().
+
 2009-04-03 Philipp Klaus Krause <pkk AT spth.de>
 
        * device/lib/z80/mul.s,
index a6e3a247b9d9d2f52bcb61cc75f8f132133781dc..fc94f60c1e323250f438d5c0165c9f71238e0328 100644 (file)
@@ -1543,10 +1543,10 @@ fetchPairLong (PAIR_ID pairId, asmop * aop, iCode *ic, int offset)
           }
         else
           {
-            /* Swapping register contents within register pair */
-            if(!strcmp(aopGet (aop, offset, FALSE), _pairs[pairId].h))
+            /* Operand resides (partially) in the pair */
+            if(!strcmp(aopGet (aop, offset + 1, FALSE), _pairs[pairId].l))
               {
-                emit2 ("ld a,%s",aopGet (aop, offset + 1, FALSE));
+                emit2 ("ld a,%s", aopGet (aop, offset + 1, FALSE));
                 emit2 ("ld %s,%s", _pairs[pairId].l, aopGet (aop, offset, FALSE));
                 emit2 ("ld %s,a", _pairs[pairId].h);
               }
@@ -5016,7 +5016,7 @@ gencjneshort (operand * left, operand * right, symbol * lbl)
             }
           else
             {
-              emit2 ("sub %s", aopGet (AOP (right), offset, FALSE));
+              emit2 ("sub a,%s", aopGet (AOP (right), offset, FALSE));
               emit2 ("jp NZ,!tlabel", lbl->key + 100);
             }
           offset++;
@@ -5040,7 +5040,7 @@ gencjneshort (operand * left, operand * right, symbol * lbl)
           emit2 ("; direct compare");
           _emitMove (_pairs[pair].l, aopGet (AOP (left), offset, FALSE));
           _moveA (aopGet (AOP (right), offset, FALSE));
-          emit2 ("sub %s", _pairs[pair].l);
+          emit2 ("sub a,%s", _pairs[pair].l);
           emit2 ("!shortjp NZ,!tlabel", lbl->key + 100);
           offset++;
         }
@@ -6752,10 +6752,9 @@ genUnpackBits (operand * result, int pair)
         {
           /* signed bitfield */
           symbol *tlbl = newiTempLabel (NULL);
-
-          emit2 ("bit %d,a", blen - 1);
+          emit2 ("bit %d,a", blen - 1 - 8);
           emit2 ("jp Z,!tlabel", tlbl->key + 100);
-          emit2 ("or a,!immedbyte", (unsigned char) (0xff << blen));
+          emit2 ("or a,!immedbyte", (unsigned char) (0xff << (blen - 8)));
           emitLabel (tlbl->key + 100);
         }
       emit2 ("ld h,a");
index 6d43c9b2439c503ca1d660a50ee2256ddffc6695..cf5a83d4f7d1ec66a522cb456f06b6a85c0f6447 100644 (file)
@@ -259,16 +259,17 @@ replace restart {
        ld      b, %2 (%3)
 } if notVolatile(%1), notUsed(%1)
 
-replace restart {
-       ld      %1,a
-       ld      %2,%3
-       ld      %4,%1
-} by {
-       ; peephole 0t loaded %4 from a instead of going through %1.
-       ld      %1,a
-       ld      %2,%3
-       ld      %4,a
-} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
+// Bug #2728445
+//replace restart {
+//     ld      %1,a
+//     ld      %2,%3
+//     ld      %4,%1
+//} by {
+//     ; peephole 0t loaded %4 from a instead of going through %1.
+//     ld      %1,a
+//     ld      %2,%3
+//     ld      %4,a
+//} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
 
 replace restart {
        ld      %1,a
index 911900b980637179c8fcc3d0d2daa80ab6df3b0c..77014fd3b9bcad01a45bc67f619dec8bae71160f 100644 (file)
@@ -22,6 +22,10 @@ void testmemory(void)
   ASSERT(destination[2] == source[2]);
   ASSERT(destination[3] == 23);
 
+  /* Test memcmp() */
+  memcpy(destination, source, 4);
+  ASSERT(memcmp(destination, source, 4) == 0);
+
   /* Test memmove() */
   memcpy(destination, source, 4);
   memmove(destination, destination + 1, 3);