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

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

[avr-gcc-list] code generation


From: Torsten Hahn
Subject: [avr-gcc-list] code generation
Date: Mon, 27 Oct 2003 15:56:07 +0100

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.



reply via email to

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