;-------------------------mbinmul routine begins--------------------------+
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
;         page : 120
;
; NAME  MBINMUL
;
; ROUTINE FOR Multidigit Binary Multiplication
;
; FUNCTION: This routine multiplies two multidigit binary numbers.
;
; INPUT: Upon entry DS:SI points to the first number; DS:DI points to
; the second number, and DS:BX points to the location where the result
; will be stored.  The size of these multidigit numbers is controlled
; by the constant ISIZE.  The input numbers contain 16*ISIZE number of
; bits and the output number has double that precision.  Both inputs are
; stored in ISIZE number of 16-bit words of memory and the output is
; stored in 2*ISIZE number of 16-bit words of memory.
;
; OUTPUT: Upon exit DS:BX points to where the result is stored.
;
; REGISTERS USED:  No registers are modified.
;
; SEGMENTS REFERENCED:  Upon entry the data segment must contain
; storage for three multidigit numbers; two for input and one for output.
;
; ROUTINES CALLED:  None
;
; SPECIAL NOTES: None
;
; ROUTINE TO MULTIPLY MULTIDIGIT BINARY NUMBERS
;
mbinmul	proc	far
;
	push	si		; save registers
	push	di
	push	bx
	push	cx
	push	ax
;
; clear result buffer
	push	bx		; save result pointer BX
	mov	ax,0		; get a zero
	mov	cx,2*isize	; double precision for this number
	cld			; forward direction
;
mbinmul1:
	mov	[bx],ax		; clear the 'digit'
	inc	bx		; point to next 'digit'
	inc	bx
	loop	mbinmul1	; loop through all 'digitts'
	pop	bx		; store result pointer BX
;
	mov	cx,isize	; get the number of 16-bit 'digits'
;
mbnimul2:
	push	cx		; save counter from outter loop
	mov	dx,[si]		; get 'digit'' from 1st number
	inc	si		; point to next number
	inc	si
;
	push	bx		; save register during inner loop
	push	di
;
	mov	cx,isize	; get the number of 16-bit 'digits'
;
mbinmul3:
	push	cx		; save counter for inner loop
	push	dx		; save multiplier digit
	mov	ax,[di]		; get 'digit' from 2nd number
	inc	di		; point to next 'digit'
	inc	di
	mul	dx		; multiply
	add	[bx],ax		; add lower 'digit' to result
	inc	bx		; point to next 'digit'
	inc	bx
	adc	[bx],dx		; add upper part to result
	pop	dx		; restore multiplier
	pop	cx		; restore counter for inner loop
	loop	mbinmul3	; loop through all 'digits' of second
;
	pop	di		; restore registers
	pop	bx
;
	inc	bx		; shift by on 'digit'
	inc	bx
	pop	cx		; restore counter for outer loop
	loop	mbinmul2	; loop through all 'digits' of first
;
	pop	ax		; restore registers
	pop	cx
	pop	bx
	pop	di
	pop	si
	ret
;
	ret			; return
;
mbinmul	endp
;-------------------------mbinmul routine ends---------------------------