	SUBTITLE    "< MULDIV/ASM - 16 x 8 multiplication & division. >"
	SCOPE
; 	2022-09-16 updated V 6.3.1 dpm

;	Multiply HL by A - SVC 91
;	HL => multiplicand
;	A  => multiplier
;	HLA <= 24-bit result
;	DE destroyed

zMUL16	PUSH	BC		;Save reg BC
	EX	DE,HL		;Multiplicand to DE
	LD	C,A		;& multiplier to C
	LD	HL,0		;Init value to zero
	LD	A,L		;in regs HLA
	LD	B,8		;Init for 8-bit mult
$?1	ADD	HL,HL		;Shift to next place
	RLA			;Use A for bits 16-23
	RLC	C		;Multiply this bit?
	JR	NC,$?2		;Go if not
	ADD	HL,DE		;Else add multiplicand
	ADC	A,0		;& any overflow to 16
$?2	DJNZ	$?1		;Loop for 8 bits
	LD	C,A		;Tempy save
	LD	A,L		;Xfer low-order to A
	Ld	L,H		;Xfer mid-order to L
	LD	H,C		;Xfer hi-order to H
	POP	BC
	RET

