home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.msdos.programmer
- Path: sparky!uunet!spool.mu.edu!uwm.edu!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!undergrad.math.waterloo.edu!rtczegle
- From: rtczegle@undergrad.math.waterloo.edu (Richard Czegledi)
- Subject: Re: This is strange, div doesn't work....
- Message-ID: <BzIxL9.28B@undergrad.math.waterloo.edu>
- Organization: University of Waterloo
- References: <1gp6q9INNgdd@aludra.usc.edu> <1992Dec18.094825.14710@miavx1.acs.muohio.edu>
- Date: Sat, 19 Dec 1992 20:43:57 GMT
- Lines: 27
-
- In article <1992Dec18.094825.14710@miavx1.acs.muohio.edu> sjmadsen@apsvax.aps.muohio.edu (Steve Madsen) writes:
- >Michael Duffy (mduffy@aludra.usc.edu) wrote:
- >: The following code gives me a divide error:
- >:
- >: mov ax,0035h
- >: mov dx,01h
- >: div dx
- >:
- >
- > I'm not a genius at assembler, but after looking in my TASM 3.2
- >quick-ref, this is about the only thing I could come up with:
- >
- > What it appears is that you are doing a simple 16-bit divide.
- >As far as my manual is concerned, if you do a div instruction with a
- >16-bit operand (such as dx in your example), then it uses DX:AX as your
- >dividend. This might be why you are having a problem, but it's only a
- >guess.
- >
- > 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.
-
- You are getting divide errors because the quotient cannot be stored within
- a 16 bit registers (ie. AX). Division on an 80x86 stores the quotient in AX
- and the remainder in DX assuming that you are performing 16 bit divisions.
- I think that you have to check that the quotient will not be larger than
- 16 bits before performing the division.
-