Rewrote 8-bit multiplication by constant, implements #1898231
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2008 16:18:04 +0000 (16:18 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2008 16:18:04 +0000 (16:18 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5041 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/z80/gen.c

index 506b5b01d776e01f7f0b8f70c59bbd385a14e961..e0b1aa68bd8c6e2c947afaefd305e873fd2ec95d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
+2008-02-22 Philipp Klaus Krause <pkk AT spth.de>
+
+       * src/z80/gen.c (genMult): Rewrote 8-bit multiplication by constant,
+          implements #1898231
+
 2008-02-22 Philipp Klaus Krause <pkk AT spth.de>
 
        * device/lib/z80/mul.s: Rewrote __muluchar_rrx_s, to improve 8-bit mult.,
-          implements #1896290.
+          implements #1896290
 
 2008-02-22 Maarten Brock <sourceforge.brock AT dse.nl>
 
index 9e995211db9a99afdbd95bf0cb03cf2e35f2e4c0..f957a6ac9ab98aa2655727e6c1e92542efa56a10 100644 (file)
@@ -4231,7 +4231,9 @@ genMult (iCode * ic)
     _G.stack.pushedDE = TRUE;
   }
 
-  if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic)))))
+  if (byteResult)
+    emit2 ("ld a,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
+  else if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic)))))
     {
       emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
       if (!byteResult)
@@ -4249,25 +4251,33 @@ genMult (iCode * ic)
 
   i = val;
 
-  /* Fully unroled version of mul.s.  Not the most efficient.
-   */
   for (count = 0; count < 16; count++)
     {
       if (count != 0 && active)
         {
-          emit2 ("add hl,hl");
+          if (byteResult)
+            emit2 ("add a,a");
+          else
+            emit2 ("add hl,hl");
         }
       if (i & 0x8000U)
         {
           if (active == FALSE)
             {
-              emit2 ("ld l,e");
-              if (!byteResult)
-                emit2 ("ld h,d");
+              if (byteResult)
+                emit2("ld e,a");
+              else
+                {
+                  emit2 ("ld l,e");
+                  emit2 ("ld h,d");
+                }
             }
           else
             {
-              emit2 ("add hl,de");
+              if (byteResult)
+                emit2 ("add a,e");
+              else
+                emit2 ("add hl,de");
             }
           active = TRUE;
         }
@@ -4283,7 +4293,7 @@ genMult (iCode * ic)
     }
 
   if (byteResult)
-    aopPut (AOP (IC_RESULT (ic)), _pairs[PAIR_HL].l, 0);
+    aopPut (AOP (IC_RESULT (ic)), "a", 0);
   else
     commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);