h31168
s 00061/00000/00000
d D 1.1 83/03/24 15:09:16 lib 1 0
c date and time created 83/03/24 15:09:16 by lib
e
u
4
U
t
T
I 1
;     INTEGER FUNCTION MULT (MUL1, MUL2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                                                      ;
;          THIS MATERIAL IS CONFIDENTIAL AND IS FURNISHED UNDER        ;
;          A WRITTEN LICENSE AGREEMENT.  IT MAY NOT BE USED,           ;
;          COPIED OR DISCLOSED TO OTHERS EXCEPT IN ACCORDANCE          ;
;          WITH THE TERMS OF THAT AGREEMENT.                           ;
;                                                                      ;
;          COPYRIGHT (C) 1982 GRAPHIC SOFTWARE SYSTEMS INC.            ;
;          ALL RIGHTS RESERVED.                                        ;
;                                                                      ;
;     FUNCTION: MULTIPLY 2 UNSIGNED 16-BIT INTEGERS                    ;
;                                                                      ;
;     INPUT PARAMETERS:                                                ;
;            MUL1, MUL2 - TWO 16-BIT INTEGERS TO MULTIPLY              ;
;                                                                      ;
;     OUTPUT PARAMETERS:                                               ;
;            MULT = (MUL1 * MUL2)                                      ;
;                                                                      ;
;     ROUTINES CALLED:                                                 ;
;            NONE                                                      ;
;                                                                      ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	.8080
mult:   entry   mult
	mov	c,m		; get multiplicand in bc
	inx	h
	mov	b,m		
	xchg			; get multiplier in de
	mov	e,m
	inx	h
	mov	d,m		
 
; Multiply 2 16-bit numbers to yield 32 bit result
; Numbers to be multiplied are in BC and DE
; The 32 bit result is in DE HL
 
	lxi	h,0		;initialize partial product
	mvi	a,16		;initialize count
loop:	dad	h		;left shift logical into carry
	xchg			;swap hl and de
	jc	mpy1		;jump if carry out from hl
	dad	h		;no carry-shift multiplier left logical into
				;carry
	jmp	mpy2
mpy1:	dad	h		;carry-shift multiplier left locigal into
	inx	h		;  carry and increment
mpy2:	xchg			;repoint to partial product
	jnc	mpy3		;jump if no add (multiplier bit in carry=0)
	dad	b		;add multiplicand in bc to partial prod in hl
	jnc	mpy3		;jump if no carry out
	inx	d		;increment de to add carry
mpy3:	dcr	a		;decrement count
	jnz	loop		;loop back if not done
	
; Least significant poriton of result is in HL. Leave it there for
; Fortran function return.

	ret
	end
 
E 1
