A86: 8-bit multiply routine


[Prev][Next][Index][Thread]

A86: 8-bit multiply routine



Here's a better 8-bit multiplication routine. It's still fairly slow, but
unless you wanted to unroll the loop or use a lookup table, you're not
going to get much faster. Anyway, I tested it, and you can get about 9000
multiplies per second.

--Joshua
;8x8 multiplication routine. This is still pretty slow, but
;I don't see how it could be made any faster...
;Anyway, I tested this, and you can do about 9000/sec.

;static stuff is 39 t-states (setup and ret)
;loop is 51 t-states if bit in multiplier set, or 40 if bit not set.
;the last time through, it's 46/35, because the djnz doesn't jump.

;HL = H * L
mulHL:
	ld a,h
	ld e,l
	ld hl,0
	ld d,h
	ld b,8
l0: rra
	jr nc,l1
	add hl,de
l1: sla e
	rl d
	djnz l0
	ret