Fixed #2051348
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 14 Aug 2008 13:12:10 +0000 (13:12 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 14 Aug 2008 13:12:10 +0000 (13:12 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5212 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/z80/gen.c
support/regression/tests/bug-2051348.c [new file with mode: 0644]

index f8f58ff7a2bd20411c2b232c8788e0c6bf3ba603..fe77709ed19396a2bb8184edf4e0dcac3e104b8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-14 Philipp Klaus Krause <pkk AT spth.de>
+       * src/z80/gen.c: fixed #2051348
+       * support/regression/tests/bug-2051348.c: regression test for #2051348
+
 2008-08-10 Raphael Neider <rneider AT web.de>
 
        * configure.in,
index 4d9d0ffbd471438b67ae36a3f074a399e85eb99d..3554803cb370a2e5de6fe2209c52e6313f947469 100644 (file)
@@ -1819,11 +1819,9 @@ aopGet (asmop * aop, int offset, bool bit16)
     case AOP_PAIRPTR:
       setupPair (aop->aopu.aop_pairId, aop, offset);
       if (aop->aopu.aop_pairId==PAIR_IX)
-        SNPRINTF (buffer, sizeof(buffer),
-                  "!*ixx", 0);
+        tsprintf (buffer, sizeof(buffer), "!*ixx", offset);
       else if (aop->aopu.aop_pairId==PAIR_IY)
-        SNPRINTF (buffer, sizeof(buffer),
-                  "!*iyx", 0);
+        tsprintf (buffer, sizeof(buffer), "!*iyx", offset);
       else
         SNPRINTF (buffer, sizeof(buffer),
                   "(%s)", _pairs[aop->aopu.aop_pairId].name);
diff --git a/support/regression/tests/bug-2051348.c b/support/regression/tests/bug-2051348.c
new file mode 100644 (file)
index 0000000..24a20d6
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+        bug 2051348.
+*/
+
+#include <testfwk.h>
+
+#pragma disable_warning 85
+
+typedef char BOOLEAN;\r
+typedef signed char SHORTINT;
+\r
+void App_PutSprite (SHORTINT x, SHORTINT y, SHORTINT spr)
+{
+}\r
+\r
+static SHORTINT Labirint_objCell, Labirint_manX, Labirint_manY, Labirint_manDirX, Labirint_manDirY;\r
+static BOOLEAN Labirint_manPresent;\r
+\r
+static SHORTINT Labirint_GetManSprite (void)
+{
+       return(0);
+}
+\r
+static BOOLEAN Labirint_ManCanGo (void)
+{
+       return(0);
+}
+\r
+static BOOLEAN Labirint_ManGoing (SHORTINT x, SHORTINT y)
+{
+       return(0);
+}
+\r
+static void Labirint_SetCell (SHORTINT x, SHORTINT y, SHORTINT cell)
+{
+}\r
+\r
+static void Labirint_TryMoveMan (void)\r
+{\r
+       SHORTINT x, y, manSprite;\r
+       if (Labirint_ManCanGo()) {\r
+               x = (Labirint_manX + Labirint_manDirX) + Labirint_manDirX;\r
+               y = (Labirint_manY + Labirint_manDirY) + Labirint_manDirY;\r
+               Labirint_manPresent = Labirint_ManGoing(x, y);\r
+               if (!Labirint_manPresent) {\r
+                       return;\r
+               }\r
+               manSprite = Labirint_GetManSprite();\r
+               Labirint_SetCell(x, y, manSprite);\r
+               App_PutSprite(Labirint_manX, Labirint_manY, 0);
+               // Assembly fails for the next two lines.\r
+               Labirint_manX = Labirint_manX + Labirint_manDirX;\r
+               Labirint_manY = Labirint_manY + Labirint_manDirY;\r
+       } else {\r
+               manSprite = 4;\r
+       }\r
+       App_PutSprite(Labirint_manX, Labirint_manY, manSprite);\r
+}
+
+void
+testBug2051348(void)
+{
+        ASSERT(1);
+}
+