Re: A89: Re: "Transfer" of values between C and ASM


[Prev][Next][Index][Thread]

Re: A89: Re: "Transfer" of values between C and ASM




Tim Boescke writes:

 > But anyways. A 400 Mhz P2/p3/Celeron does run up to 300-400 times faster
 > than the 10Mhz 68000 in your TI89, since it simply is able to do more
 > per cycle. Of course this is again limited by memory speed etc, as you
 > mentioned.

And those 256K ~ 1M caches help a lot, too ...
 
My comment on the original C vs. assembly:
You can usually beat the compiler (even a good compiler) on small CPUs 
(which, in this context, includes the 68k). Not by a huge margin, though.

On a modern CPU, on the other hand, you don't have a chance.
Most high-powered RISCs have multiple execution units, register
renaming engines, long pipelines and the whole thing depends 
heavily on caches.

Now a compiler can take all that into account every time you compile
your code. On the other hand, let's assume that you have a piece of 
assembly which you handcrafted to do everything perfectly, all
register dependencies are ballanced, all execution units are utilised, 
cache hits are maximised and so on. Now you figure out that you need
to insert just a single instruction somewhere. You can start the whole 
optimisation business again, re-ordering your whole code (effectively
rewriting the algorithmic details) and go through the works, *without* 
ever making a single mistake. You can't do that, it's too complex.
(In theory you can, but realisticly you won't.)
It does not have an 'overall big picture' that we humans can
comprehend, it is all in the little details where we easily get
lost. The compiler, on the other hand, is dumb, it can't handle large
scale fuzzy objectives and it can't take different perspectives to the
problem. It however, can, and does take care of the details,
diligently taking the code apart and rebuilding it using *local*
optimisations, dozens at a time until it reaches something that is
very good. It may not be the absolute best solution (i.e. a global
optimum) but it will usually be better than what a human can come up 
with. Especially if it is done the forty-sevenths time today ...

Regards,

Zoltan


References: