* Optimised many of the library functions
[fw/sdcc] / src / z80 / peeph.def
index a866d187b1063c0e27d2afac7f4f08e0ff271dab..00375bed908c6e805d7da9ff135fa021a033673d 100644 (file)
@@ -6,7 +6,7 @@ replace restart {
 replace restart {
        ld %1,%1
 } by {
-       ; Removed redundent load
+       ; Rule 1: Removed redundent load
 }
 replace restart {
        xor a,a
@@ -14,7 +14,6 @@ replace restart {
        or a,a
        jp %2,%3
 } by {
-       ; Removed redundent or a,a
        xor     a,a
        or      a,%1
        jp      %2,%3
@@ -23,7 +22,7 @@ replace restart {
        cp a,#0x00
        jp nz,%1
 } by {
-       ; Rule 3
+        ; Rule 3: Changed cp #0 to or
        or      a,a
        jp      nz,%1
 }
@@ -34,7 +33,7 @@ replace restart {
        jp      %3
 %2:
 } by {
-       ; Rule 4
+       ; Rule 4: Changed jp order
        jp      z,%2
 %1:
        jp      %3
@@ -45,7 +44,7 @@ replace restart {
        jp      %2
 %1:
 } by {
-       ; Rule 5
+       ; Rule 5: Changed jump logic
        jp      z,%2
 %1:
 }
@@ -54,16 +53,52 @@ replace restart {
        jp      %2
 %1:
 } by {
-       ; Rule 6
+       ; Rule 6: Changed jump logic
        jp      nz,%2
 %1:
 }
 replace restart {
-       ld      a,%1
-       or      a,%2
+       or      a,%1
        or      a,a
 } by {
-       ; Rule 8
-       ld      a,%1
-       or      a,%2
+       ; Rule 7: Removed redundent or
+       or      a,%1
+}
+replace restart {
+       or      a,%1)
+        or      a,a
+} by {
+       ; Rule 8: Removed redundent or for (ix)
+       or      a,%1)
+}
+replace restart {
+       xor     a,a
+       or      a,%1
+       jp      nz,%2
+       xor     a,a
+       or      a,%3
+       jp      z,%2
+} by {
+       xor     a,a
+       or      a,%1
+       jp      nz,%2
+       or      a,%3
+       jp      z,%2
+}
+replace restart {
+       jp      nz,%1
+       inc     %3)
+%1:
+       jp      %2
+} by {
+       jp      nz,%2
+       inc     %3)
+%1:
+       jp      %2
+}
+replace restart {
+       xor     a,a
+       ld      a,#0x00
+} by {
+        xor     a,a
 }