Applied patch #2762516
[fw/sdcc] / device / lib / z80 / mul.s
index cba10dfe93ce6edd1fadc4b591e91c68f99ac60e..e81ac80040b958cb5be49d3e9b458f748d5900d7 100644 (file)
@@ -1,47 +1,41 @@
         .area   _CODE
 
 __mulint_rrx_s::
-        ld      hl,#2
-        add     hl,sp
-
-        ld      e,(hl)
-        inc     hl
-        ld      d,(hl)
-        inc     hl
-        ld      a,(hl)
-        inc     hl
-        ld      h,(hl)
-        ld      l,a
+        pop     af
+        pop     hl
+        pop     de
+        push    de
+        push    hl
+        push    af
 
         ;; Fall through
 
 __muluchar_rrx_hds::
 __mulint_rrx_hds::
        ;; Parameters:
-       ;;      HL, DE (left, right irrelevant)
+       ;;      hl, de (left, right irrelevant)
        ld      b,h
        ld      c,l
 
        ;; 16-bit multiplication
        ;;
        ;; Entry conditions
-       ;;   BC = multiplicand
-       ;;   DE = multiplier
+       ;; bc = multiplicand
+       ;; de = multiplier
        ;;
        ;; Exit conditions
-       ;;   DE = less significant word of product
+       ;; hl = less significant word of product
        ;;
        ;; Register used: AF,BC,DE,HL
 __mul16::
-        ld      l,#0
-        ld      a,b
-        ld      b,#16
+       xor     a,a
+       ld      l,a
+       or      a,b
+       ld      b,#16
 
         ;; Optimise for the case when this side has 8 bits of data or
         ;; less.  This is often the case with support address calls.
-        or      a
         jr      NZ,2$
-
         ld      b,#8
         ld      a,c
 1$: