avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] [Bug] Initialization for _delay_loop_2 Optimized Out


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] [Bug] Initialization for _delay_loop_2 Optimized Out
Date: Thu, 24 Jul 2003 17:51:25 +0200 (MET DST)

As "Dave Hansen" <address@hidden> wrote:

>>You remember that all these calculations are done using the `int'
>>data type, i. e. a 16-bit one, unless you force it to become long,
>>do you?

>No.  From n869 6.4.4.1p5:
>
>   "The type of an integer constant is the first of the corresponding list 
>in which its value can
>    be represented."

Interesting, thanks for the clarification.  I didn't knew that yet
(and i could bet it worked differently in previous versions of at
least gcc).

I've also verified the result is indeed 16.

>Which, again, is the whole point of the bug report.  I haven't tried it (I 
>don't have the time right now), but I suspect the following:
>
>   #include <avr/delay.h>
>   int main (void)
>   {
>      while(1)
>         _delay_loop_2(3);
>
>      return 0;
>   }
>
>Would generate incorrect code.

For me, it works, and generates the following code:

..
.L6:
        ldi r24,lo8(3)
        ldi r25,hi8(3)
/* #APP */
        1: sbiw r24,1
        brne 1b
/* #NOAPP */
        rjmp .L6
..
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]