* src/z80/gen.c, src/z80/peeph.def: applied patch
[fw/sdcc] / src / z80 / peeph.def
index 90b1b2b154463a4e50e44e1ac38b62687a6e3b98..02e485b79ef257fe8c0755dcf48f0176394fe643 100644 (file)
@@ -456,6 +456,22 @@ replace restart {
        ld      %1,a
 } if notVolatile(%1)
 
+// sdcc does not use the H flag. sla resets it, while add sets it.
+// To ensure that the state of the H flag is not changed by this
+// peephole uncomment the add %3, %4 at the end (since it overwrite the H flag).
+replace restart {
+       ld      %1, a
+       sla     %1
+       ld      a, %2
+       //add   %3, %4
+} by {
+       add     a, a
+       ; peephole 42a shifts in accumulator insted of %1
+       ld      %1, a
+       ld      a, %2
+       //add   %3, %4
+}
+
 replace restart {
        ld      %1,a
        ld      a,%2