On Mon, 01 Oct 2007 13:02:32 +0530, David Brown <[EMAIL PROTECTED]> wrote:
> Royce Pereira wrote:
>> So I have to write more 'C' code :) to get the same stuff done, in
>> the 'new & smarter' compiler! Interesting.....
>> Doesn't seem right, some how.
>> Regards, --Royce.
> It might not seem right, but that's the way it is.  The compiler only
> has to generate code that has the same effect as the source you've
> written, and a simple "ret" has that effect.

Why then was the empty 'ret' function retained?
I would think such a case would be the prime candidate for optimisation.
The compiler should eliminate such a funtion, as well as all calls to that 
That would really make a difference in size/speed of the code.

(Instead, the compiler destroys a perfectly good delay loop I've used for the 
last 2 years -yes, I'm still sore)

> There is no way in C to
> express the idea of a time delay - the language has no concept of time.
>   Thus you have to go out of your way to tell the compiler to be
> particularly stupid if you want this sort of code to work.  There are
> other ways to get a delay, such as the library routines or hardware
> timers, or by including something like an "asm volatile ("nop")" in the
> loop, but using a volatile loop counter is an easy way to get an
> approximate delay loop.
Of course, there's no disputing that. But the delay loop is just an example, of 
how simple ,intuitive code can throw the compiler into a tizzy. I've used 
SDCC(for mcs51) where the compiler 'recognises' code patterns, and says "Oh, I 
know what this is - it's a delay loop! - Let it pass."(for example).

I've always maintained -  good software is one that does what you *want* it to 
do, *not* what you tell it to do. ;)

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

AVR-GCC-list mailing list

Reply via email to