To: djgpp AT delorie DOT com Subject: Re: fixed point math: NEED HELP QUICK! Message-ID: <19970201.123135.4847.3.chambersb@juno.com> References: From: chambersb AT juno DOT com (Benjamin D Chambers) Date: Sat, 01 Feb 1997 15:29:54 EST On Sat, 1 Feb 1997 05:50:56 -0500 (EST) mharris AT blackwidow DOT saultc DOT on DOT ca writes: >Write a program which demonstrates that using shifts/adds is more >efficient than using mul/divs for the majority of integer >multipliers/divisors between -32768 and +32767 (signed) and 0 and >65535 unsigned. Well, I'll give it a try :) Just for the record, I spent a few minutes on that example working out the ASM code, but for this I'll just do the mul's and shifts incrementally in ASM and do them again in C (the optimizer should switch them to shifts/muls). If I have to, I WILL NOT write out 65536 shifting routines to prove my point - I don't have that kind of time ;) But, I'll post the code when I get the results... >I highly doubt that this will be very pretty. Ditto. >If you can convince me that most (read that 90%) mul/div >operations are slower than the equiv shift add, then you >win. The prize will be your choice of; an unopened box >full of 360k disks or 25 Atari 2600 cartridges. Please, no - I've got too much junk around already (I finally got around to dumping my boxes of 5 1/4 inch diskettes that I haven't touched for 2 years :) >I want to see the source code, and also profiled output >showing that shifts are faster than muls as stated above. >(Instead of profiled output you can make the program keep >it's own statistics and output them to a file.) > >Processor aim is 386, 486, and Pentium. I only have access to a 486, maybe somebody can do the others. > >Good luck. I'm packaging up those cartridges. :o) > >Hey, can you do square roots in less than 10 cycles too? I wish :) The current method I use when I don't have a calculator handy is rather inaccurate with larger numbers, and wouldn't translate very well into machine code. ...Chambers