[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] code generation
From: |
J.C. Wren |
Subject: |
Re: [avr-gcc-list] code generation |
Date: |
Mon, 27 Oct 2003 11:14:51 -0400 |
User-agent: |
KMail/1.5.4 |
It's a lack of understanding the keyword 'volatile'. 'volatile' means that it
may be changed between reference by an external influence. If it doesn't
update it, it wouldn't be 'volatile'.
--John
On Monday 27 October 2003 09:56 am, Torsten Hahn wrote:
> Hi, compiling a code like this in an interrupt handler
>
> ------------------------
> extern volatile uint16_t cnt;
>
> if(!cnt--) {
> asm("nop");
> }
>
> -------------------------
>
> gives this code:
>
> (avr-gcc (GCC) 3.3.1), with -O2
>
> ....
> 0 push r24
> 1 push r25
> 2 lds r24, 0x0113
> 3 lds r25, 0x0114
> 4 sbiw r24, 0x01 ; 1
> 5 sts 0x0114, r25
> 6 sts 0x0113, r24
> 7 lds r24, 0x0113
> 8 lds r25, 0x0114
> 9 or r24, r25
> 10 brne .+2 ; 0x5d6
> 11 nop
> ....
>
> I think the code in lines 5, 6, 7 and 8 is a bit inefficient. Why
> storing the regs to sram and loading them back again ? How can i help
> the compiler to do a better job there ?
>
> thx,
> Torsten.
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list