Added mulAbyHL

This commit is contained in:
Stephen Toth 2018-06-26 21:34:22 -04:00
parent 240d49b928
commit 05787a20e3
3 changed files with 18 additions and 38 deletions

View File

@ -12,7 +12,6 @@ Setup:
LD HL, 0
CALL fshvarfill
Input:
LD C, $00
CALL fshcmdfill

Binary file not shown.

View File

@ -28,6 +28,7 @@ cpBCDE:
sbc hl, de
pop hl
ret
;; mulAbyB
;; Multiplys AxB
;; Inputs:
@ -45,50 +46,30 @@ mulAbyBLoop:
pop bc
ret
;; mul8By8 [Maths]
;; Performs an unsigned multiplication of H and E
;; mulAbyHL
;; Multiplys AxHL
;; Inputs:
;; H: Multiplier
;; E: Multiplicand
;; A: Multiplier
;; HL: Multiplicand
;; Outputs:
;; HL: Product of H and E.
mul8By8:
;; HL: Product of A and HL.
mulAbyHL:
push bc
push de
ld l, 0
ld d, l
sla h
jr nc, $ + 3
ld l, e
add hl, hl
jr nc, $ + 3
ld de, 0
ex de, hl
cp 0
jr z, mulAbyHLEnd
ld b, a
mulAbyHLLoop:
add hl, de
add hl, hl
jr nc, $ + 3
add hl, de
add hl, hl
jr nc, $ + 3
add hl, de
add hl, hl
jr nc, $ + 3
add hl, de
add hl, hl
jr nc, $ + 3
add hl, de
add hl, hl
jr nc, $ + 3
add hl, de
add hl, hl
jr nc, $ + 3
add hl, hl
jr nc, $ + 3
add hl, de
add hl, de
djnz mulAbyHLLoop
mulAbyHLEnd:
pop de
pop bc
ret
;; mul32By8 [Maths]
;; Performs an unsigned multiplication of DEHL and A.
;; Outputs: