home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / programm / 2569 < prev    next >
Encoding:
Text File  |  1992-09-04  |  1.4 KB  |  36 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!irving
  3. From: irving@casbah.acns.nwu.edu (Thomas Myers)
  4. Subject: Assembly Alogrithm Needed
  5. Message-ID: <1992Sep4.125255.29945@news.acns.nwu.edu>
  6. Summary: Help with DIVIDE routine
  7. Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
  8. Organization: Northwestern University, Evanston, Illinois, USA
  9. Date: Fri, 4 Sep 1992 12:52:55 GMT
  10. Lines: 24
  11.  
  12.  
  13. We have a hardware circuit which needs to divide integers using a Motorola
  14. 68HC05 chip.  The instruction set contains only a limited complement of
  15. instructions, notable missing is a divide instuction.  It is an 8 bit chip with
  16. stack, Accumulator, Index Register and Flags.
  17.  
  18. What we need to do is to divide two 8 bit integers with a precision of two
  19. (2) decimal places (ie 246/127 = 1.94).  It also must be as fast as possible.
  20.  
  21. The algorithm I devised seems too brute force:
  22.  
  23.     1.  Loop:  Subtract  Den from Num incrementing Quot
  24.     2.         Multiply  Num and Quot by 10
  25.     3.  Etc. for two decimal places...
  26.  
  27. In order to accomplish this, more than 8 bits need to be used to represent the
  28. Numerator (ie Remainder times 10 exceeds 255).  The algortihm to force a 16
  29. bit representation of the numerator is pretty wretched.
  30.  
  31. I'm sure that there must be tried and true mechanisms to accomplish this.
  32.  
  33. Please contact me if you have suggestions or need further information.
  34.  
  35. Thanks
  36.