[misc.wanted] Need Assembler Source for 32-bit Division routine

barry@micomvax.UUCP (02/09/87)

To any experienced Assmebler programmer:

I am working with an IBM AT clone running MS-DOS 3.10 and what i need is the
following:

(1) An assembler routine to do 32-bit by 16-bit division yielding a 32-bit
    result (not a 16-bit result as the opcode DIV yields)


Any help anyone out there can give me would be greatly appreciated.
Thanks in advance for all your help.

Please send any and all replies by mail to
	...!philabs!micomvax!barry


Barry Kimelman		[ UUCP address:  ...!philabs!micomvax!barry ]
phone: (514) 744-8200 ext. 2473

Nothing is impossible if you do not have to do it yourself !!
It is not enough that i succeed , everyone else must fail !!

herman@ti-csl.UUCP (02/12/87)

in article <766@micomvax.UUCP>, barry@micomvax.UUCP (Barry Kimelman) says:
> 
> I am working with an IBM AT clone running MS-DOS 3.10 and what i need is the
> following:
> 
> (1) An assembler routine to do 32-bit by 16-bit division yielding a 32-bit
>     result (not a 16-bit result as the opcode DIV yields)
> 
> Barry Kimelman		[ UUCP address:  ...!philabs!micomvax!barry ]
> phone: (514) 744-8200 ext. 2473

Simple, use DIV twice, as in:

	DIV	CX	; DX|AX / CX => AX = quotient, DX = remainder
	XCHG	BX,AX	; Exchange quotient with next chunk of dividend
	DIV	CX	; AX = low 16 bits of quotient, DX = remainder

This will divide the 48-bit dividend in DX|AX|BX (high|middle|low) by the
16-bit divisor in CX.  The 32-bit result will be returned in BX|AX (high|low)
with the 16-bit remainder in DX.  As long as you stay with unsigned division,
this principle can be extended to any length dividend divided by a 16-bit
divisor, just by taking the remainder of the previous division as the high
16 bits of the next division, and the next 16 bits of the dividend as the low
16 bits for DIV.

-- 
Herman Schuurman 	ARPA:  herman%TI-CSL@CSNET-RELAY.ARPA
Texas Instruments Inc.	CSNET: herman@TI-CSL
PO Box 226015 M/S 238	USENET: {ut-sally,convex!smu,texsun,rice}!ti-csl!herman
Dallas, Texas 75266	VOICE: (214) 995-0845