Faster 8-bit multiplication: #1896290
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2008 14:46:58 +0000 (14:46 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2008 14:46:58 +0000 (14:46 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5040 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/lib/z80/mul.s

index 1a673ab0ae1ef052ca7a91988591419ca55ca6d4..506b5b01d776e01f7f0b8f70c59bbd385a14e961 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2008-02-22 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/SDCCast.c (createIvalStruct): fixed bug 1466761
index 00e6ce9ee2e9747a980aab13522a1c7a3d74b102..a638e0686bbedf229fb6a192b946728c80c21f8d 100644 (file)
@@ -1,6 +1,26 @@
-       ;; Originally from GBDK by Pascal Felber.
+        .area   _CODE
 
-       .area   _CODE
+; This multiplication routine is similar to the one
+; from Rodnay Zaks, "Programming the Z80".
+
+__muluchar_rrx_s::
+        ld      hl, #2
+        add     hl, sp
+        ld      e, (hl)
+        inc     hl
+        ld      h, (hl)
+        ld      l, #0
+        ld      d, l
+        ld      b, #8
+muluchar_rrx_s_loop:
+        add     hl, hl
+        jr      nc, muluchar_rrx_s_noadd
+        add     hl, de
+muluchar_rrx_s_noadd:
+        djnz    muluchar_rrx_s_loop
+        ret
+
+;; Originally from GBDK by Pascal Felber.
 
 __mulschar_rrx_s::
         ld      hl,#2
@@ -27,22 +47,6 @@ __mulschar_rrx_hds::
 
         jp      .mul16
 
-__muluchar_rrx_s::
-        ld      hl,#2
-        add     hl,sp
-
-        ld      e,(hl)
-
-        inc     hl
-        ld      c,(hl)
-
-        ;; Clear the top
-        xor     a
-        ld      d,a
-        ld      b,a
-
-        jp      .mul16
-
 __mulint_rrx_s::
         ld      hl,#2
         add     hl,sp