🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #15259

Re: Need Assembler Source for 32-bit Division routine

#15259
From: herman
Date: Thu, 12 Feb 1987 18:57
30 lines
1935 bytes
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
Technical Details
Message-ID: <14209@ti-csl.CSNET>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!brl-adm!seismo!ut-sally!ut-ngp!infotel!pollux!ti-csl!herman
References: <766@micomvax.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!brl-adm!seismo!ut-sally!ut-ngp!infotel!pollux!ti-csl!herman
From: herman@ti-csl.UUCP
Newsgroups: comp.sys.ibm.pc,comp.sources.wanted,misc.wanted
Subject: Re: Need Assembler Source for 32-bit Division routine
Message-ID: <14209@ti-csl.CSNET>
Date: Thu, 12-Feb-87 13:57:15 EST
Article-I.D.: ti-csl.14209
Posted: Thu Feb 12 13:57:15 1987
Date-Received: Fri, 13-Feb-87 22:44:19 EST
References: <766@micomvax.UUCP>
Distribution: world
Organization: TI Computer Science Center, Dallas
Lines: 30