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