Hey, Phillip. Sorry it took so long responding to your post - I've been away and am just getting caught up. I don't have a readily available copy of a multiply routine using shift and add techniques, but I'm SURE I can do one pretty quickly if you still need one. It's really very simple. On the other hand, I HAVE written an assembly language version of a high-precision integer divide routine using shift & subtracts that uses 4-byte integers for dividend, divisor, quotient, and remainder. If you send me an off-line message with your email address I'll send you a copy of it (also anyone else who might be interested). Because the program I incorporated it in required every quotient to be a positive integer, the result is always positive, with a flag set indicating whether the answer should really be considered negative. It is really simpler to let the divide routine treat all numbers as they really are, but that's not what I needed at the time. It DOES treat all incoming info in it's native state (positive or negative), just that the answer will always be positive with the accompanying flag indicating the polarity. The routine could be modified easily to return true negative answers if desired. The code is heavily commented, so it should be readily apparent what's happening. Let me know if it'd help! Dennis Philip Pemberton wrote: >Hi all, > I've attached some code I've been working on - a simple multiple-precision >maths library written in C. I've got the add/subtract/multiply/divide stuff >working, but I'm having a hard time finding some information on alternative >multiplication and division routines. > At the moment, the code uses a brute-force (repeated subtraction) division >routine and a very nasty multiplication routine. I'd like to get rid of the >16-bit multiply in the multiplication routine and find a faster division >routine. On a PC, it doesn't really matter how inefficient the code is, >simply due to the high speeds of the CPUs in most modern PCs. The catch is, >when I run this code on a PIC, every cycle counts. > I've heard about a set of routines that use shifts, adds and subtracts to >perform division and multiplication, but I can't find any usable information >on them (i.e. pseudocode). > Has anyone ever done anything like this? > >Thanks. >-- >Phil. | Acorn Risc PC600 Mk3, SA202, 64MB, 6GB, >philpem@dsl.pipex.com | ViewFinder, 10BaseT Ethernet, 2-slice, >http://www.philpem.dsl.pipex.com/ | 48xCD, ARCINv6c IDE, SCSI >... Sorry... my mind has a few bad sectors. > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. > > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu