* support/regression/tests/bug-478094.c: Added.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 5 Nov 2001 01:40:22 +0000 (01:40 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 5 Nov 2001 01:40:22 +0000 (01:40 +0000)
* src/z80/gen.c (commitPair): Fixed silly gbz80/z80 commit to static bug.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1502 4a8a32a2-be11-0410-ad9d-d568d2c75423

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

index 6922a4a240c55d9b58445c71358af2e2e5638646..0700abecd3df54244688ab7dd8a8f9aa7a18c8a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-04  Michael Hope  <michaelh@juju.net.nz>
+
+       * support/regression/tests/bug-478094.c: Added.
+
+       * src/z80/gen.c (commitPair): Fixed silly gbz80/z80 commit to static bug.
+
 2001-11-04  Bernhard Held  <bernhard@bernhardheld.de>
 
        * sdcc/sim/ucsim/s51.src/uc390cl.h: Improvement for ds390 to run regression tests
index 6c5d5ae74ab3eecd5fd7db2e6b1e0692a6fced03..b9e9569a832c9b2d7b3611ae14b4fe94c939a2c2 100644 (file)
@@ -1618,7 +1618,8 @@ aopPut (asmop * aop, const char *s, int offset)
 static void
 commitPair (asmop * aop, PAIR_ID id)
 {
-  if (id == PAIR_HL && requiresHL (aop))
+  /* PENDING: Verify this. */
+  if (id == PAIR_HL && requiresHL (aop) && IS_GB)
     {
       emit2 ("ld a,l");
       emit2 ("ld d,h");
@@ -1627,8 +1628,19 @@ commitPair (asmop * aop, PAIR_ID id)
     }
   else
     {
-      aopPut (aop, _pairs[id].l, 0);
-      aopPut (aop, _pairs[id].h, 1);
+      /* Special cases */
+      if (id == PAIR_HL && aop->type == AOP_IY && aop->size == 2)
+        {
+          char *l = aopGetLitWordLong (aop, 0, FALSE);
+          wassert (l);
+
+          emit2 ("ld (%s),%s", l, _pairs[id].name);
+        }
+      else
+        {
+          aopPut (aop, _pairs[id].l, 0);
+          aopPut (aop, _pairs[id].h, 1);
+        }
     }
 }
 
diff --git a/support/regression/tests/bug-478094.c b/support/regression/tests/bug-478094.c
new file mode 100644 (file)
index 0000000..c2de561
--- /dev/null
@@ -0,0 +1,36 @@
+/* Tests a commit problem.
+ */
+#include <testfwk.h>
+
+
+
+int foo = 16; 
+
+extern void f( int x ); 
+
+void g(int bar) 
+{ 
+  int a = 0; 
+  int b = 0; 
+
+  while(1) { 
+    switch(bar) { 
+    case 0: 
+      --foo; 
+      f(foo); 
+      break; 
+    case 1: 
+      ++foo; 
+      f(foo); 
+      break; 
+    case 2: 
+      ++a; 
+      f(a); 
+      break; 
+    case 3: 
+      ++b; 
+      f(b); 
+      break; 
+    } 
+  } 
+}