X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fz80%2Fmul.s;h=e81ac80040b958cb5be49d3e9b458f748d5900d7;hb=5a1d5e778e85664f4e6657019348b4756b16eacb;hp=b54fd9d73962dbad55f1c08b3dc0d4c1abf0e575;hpb=2109a06030f5d8dcb7412a67cf61315e6f69a427;p=fw%2Fsdcc diff --git a/device/lib/z80/mul.s b/device/lib/z80/mul.s index b54fd9d7..e81ac800 100644 --- a/device/lib/z80/mul.s +++ b/device/lib/z80/mul.s @@ -1,59 +1,53 @@ .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 hl,#0 - ld a,b - ; ld c,c - 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,1$ - + jr NZ,2$ ld b,#8 ld a,c 1$: ;; Taken from z88dk, which originally borrowed from the ;; Spectrum rom. add hl,hl +2$: rl c rla ;DLE 27/11/98 - jr NC,2$ + jr NC,3$ add hl,de -2$: +3$: djnz 1$ ret