home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / alt / msdos / programm / 2973 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.6 KB  |  38 lines

  1. Newsgroups: alt.msdos.programmer
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!undergrad.math.waterloo.edu!rtczegle
  3. From: rtczegle@undergrad.math.waterloo.edu (Richard Czegledi)
  4. Subject: Re: This is strange, div doesn't work....
  5. Message-ID: <BzIxL9.28B@undergrad.math.waterloo.edu>
  6. Organization: University of Waterloo
  7. References: <1gp6q9INNgdd@aludra.usc.edu> <1992Dec18.094825.14710@miavx1.acs.muohio.edu>
  8. Date: Sat, 19 Dec 1992 20:43:57 GMT
  9. Lines: 27
  10.  
  11. In article <1992Dec18.094825.14710@miavx1.acs.muohio.edu> sjmadsen@apsvax.aps.muohio.edu (Steve Madsen) writes:
  12. >Michael Duffy (mduffy@aludra.usc.edu) wrote:
  13. >: The following code gives me a divide error:
  14. >: 
  15. >:  mov  ax,0035h
  16. >:  mov  dx,01h
  17. >:  div  dx
  18. >:
  19. >
  20. >    I'm not a genius at assembler, but after looking in my TASM 3.2
  21. >quick-ref, this is about the only thing I could come up with:
  22. >
  23. >    What it appears is that you are doing a simple 16-bit divide.
  24. >As far as my manual is concerned, if you do a div instruction with a
  25. >16-bit operand (such as dx in your example), then it uses DX:AX as your
  26. >dividend.  This might be why you are having a problem, but it's only a
  27. >guess.
  28. >
  29. >    You could try changing DX to DL and see if that works.  Since
  30. >you are assigned DX to what looks like a byte value anyway, this might
  31. >solve your problem. 
  32.  
  33. You are getting divide errors because the quotient cannot be stored within
  34. a 16 bit registers (ie. AX).  Division on an 80x86 stores the quotient in AX
  35. and the remainder in DX assuming that you are performing 16 bit divisions.
  36. I think that you have to check that the quotient will not be larger than
  37. 16 bits before performing the division. 
  38.