Article View: alt.msdos.programmer
Article #848Re: This is strange, div doesn't work....
From: Charles M. Heard heard
Date: Sun, 20 Dec 1992 07:34
Date: Sun, 20 Dec 1992 07:34
25 lines
1565 bytes
1565 bytes
Michael Duffy (mduffy@aludra.usc.edu) wrote: >: The following code gives me a divide error: >: >: mov ax,0035h >: mov dx,01h >: div dx Yes indeed. The 80x86 will give you a divide error anytime the quotient is too large to fit into the destination register. This code divides the 32-bit unsigned integer in DX:AX -- namely 010035H -- by the 16-bit unsigned integer in DX -- namely 0001H -- and is supposed to return the quotient -- 010035H -- in AX (with the remainder in DX). It won't fit, so a divide exception is raised. In article <1992Dec18.094825.14710@miavx1.acs.muohio.edu> sjmadsen@apsvax.aps.muohio.edu (Steve Madsen) writes: > You could try changing DX to DL and see if that works. Since >you are assigned DX to what looks like a byte value anyway, this might >solve your problem. This will not raise the exception, but it changes the instruction semantics. It divides the 16-bit unsigned number in AX by the 8-bit number in DL and returns the quotient in AL and the remainder in AH. So "div dl" would function as a no-op with 0035H in AX and 01H in DL. heard
Technical Details
Message-ID:
<8506@public.BTR.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sgiblab!public!heardReferences:
<1gp6q9INNgdd@aludra.usc.edu> <1992Dec18.094825.14710@miavx1.acs.muohio.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sgiblab!public!heard From: heard@public.BTR.COM (Charles M. Heard heard@btr.com) Newsgroups: alt.msdos.programmer Subject: Re: This is strange, div doesn't work.... Message-ID: <8506@public.BTR.COM> Date: 20 Dec 92 07:34:59 GMT References: <1gp6q9INNgdd@aludra.usc.edu> <1992Dec18.094825.14710@miavx1.acs.muohio.edu> Organization: BTR Public Access UNIX, MtnView CA. For info contact: info@BTR.COM Lines: 25