[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Problem with delay loop
From: |
Royce Pereira |
Subject: |
Re: [avr-gcc-list] Problem with delay loop |
Date: |
Wed, 03 Oct 2007 00:23:46 +0530 |
User-agent: |
Opera Mail/9.22 (Win32) |
Hi,
On Mon, 01 Oct 2007 13:02:32 +0530, David Brown <address@hidden> 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
function.
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. ;)
Regards,
--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
- Re: [avr-gcc-list] Problem with delay loop, (continued)
- RE: [avr-gcc-list] Problem with delay loop, Eric Weddington, 2007/10/02
- Re: [avr-gcc-list] Problem with delay loop, Bob Paddock, 2007/10/01
- RE: [avr-gcc-list] Problem with delay loop, John Regehr, 2007/10/02
- RE: [avr-gcc-list] Problem with delay loop, Eric Weddington, 2007/10/02
- RE: [avr-gcc-list] Problem with delay loop, John Regehr, 2007/10/02
- Re: [avr-gcc-list] Problem with delay loop, David Brown, 2007/10/01
- Re: [avr-gcc-list] Problem with delay loop, Paulo Marques, 2007/10/01
- Re: [avr-gcc-list] Problem with delay loop, David Brown, 2007/10/02
Re: [avr-gcc-list] Problem with delay loop,
Royce Pereira <=