shithub: mc

Download patch

ref: e3670dfc5c38e7c42971b833738e6cd265ca77f9
parent: 64f02da800fa67fc90084cdef6c6fee0dc24e9dd
author: Ori Bernstein <[email protected]>
date: Wed Mar 20 09:57:13 EDT 2013

Use 'lea' to calculate offset addresses.

    Again, shorter and easier to understand code. Possibly faster too.

--- a/6/isel.c
+++ b/6/isel.c
@@ -360,13 +360,18 @@
     sp = inr(s, from);
     dp = inr(s, to);
 
-    g(s, Imov, len, locphysreg(Rrcx), NULL); /* length to blit */
-    g(s, Imov, sp, locphysreg(Rrsi), NULL); /* source index */
-    g(s, Imov, dp, locphysreg(Rrdi), NULL); /* dest index */
+    /* length to blit */
+    g(s, Imov, len, locphysreg(Rrcx), NULL);
+    /* source address with offset */
     if (srcoff)
-        g(s, Iadd, loclit(srcoff, ModeQ), locphysreg(Rrsi), NULL);
+        g(s, Ilea, locmem(srcoff, sp, NULL, ModeQ), locphysreg(Rrsi), NULL);
+    else
+        g(s, Imov, sp, locphysreg(Rrsi), NULL);
+    /* dest address with offset */
     if (dstoff)
-        g(s, Iadd, loclit(dstoff, ModeQ), locphysreg(Rrdi), NULL);
+        g(s, Ilea, locmem(dstoff, dp, NULL, ModeQ), locphysreg(Rrdi), NULL);
+    else
+        g(s, Imov, dp, locphysreg(Rrdi), NULL);
     g(s, op, NULL);
 }