From: mharris AT blackwidow DOT saultc DOT on DOT ca Date: Sun, 2 Feb 1997 13:43:33 -0500 (EST) Reply-To: mharris AT blackwidow DOT saultc DOT on DOT ca To: Benjamin D Chambers cc: djgpp AT delorie DOT com Subject: Re: fixed point math: NEED HELP QUICK! In-Reply-To: <19970201.123135.4847.3.chambersb@juno.com> Message-ID: Organization: Total disorganization. MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 1 Feb 1997, Benjamin D Chambers wrote: > >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... Great! The result is sure to be a useful program for us manual optimizers. I think it will boil down to the number of 1 bits in the multiplier however. > >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 :) Ok, the prize will be... Hmm. I've got no idea. A copy of the latest DJGPP with sources? How's that? > >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. I can test the program on a 386 (I'm the lucky owner of a DX40!) Also I've got a 286-8Mhz and a 486/66. > >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. Hmm. I was really hoping to get rid of those carts... Oh well. :o) Mike A. Harris | http://blackwidow.saultc.on.ca/~mharris Computer Consultant | My webpage has moved and my address has changed. My dynamic address: http://blackwidow.saultc.on.ca/~mharris/ip-address.html mailto:mharris AT blackwidow DOT saultc DOT on DOT ca Question: Will Linus trash the Linux project when HURD comes out? I hope not.