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

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

Re: [avr-gcc-list] atmega64


From: Ned Konz
Subject: Re: [avr-gcc-list] atmega64
Date: Thu, 24 Jun 2004 21:53:57 -0700
User-agent: KMail/1.6.2

On Thursday 24 June 2004 4:52 pm, Iuliu Vasilescu wrote:
> I have this very simple program, and trying to run it on an atmega64:
>
> #include <inttypes.h>
> #include <avr/io.h>
> #include <avr/interrupt.h>
> #include <avr/signal.h>
>
> int i;
> void a(){
>     i=0;
> }
>
> int main (void)
> {    DDRB=255;
>       a();
>       while(1){PORTB=0;PORTB=255;};
> }
>
> if I compile it for atmega64, the program does not flip the B port at
> all (like never returns from a())
> if I compile it for atmega16 runs ok on both atmega64 and atmega16...
> I am using winavr-20040404.

Well, using gcc-3.4.0 on Linux, I get exactly the same assembly output (except 
for the .arch line, of course) on both processors.

You don't say what flags you're using, but if I use -O3 I get the following. 
Note that though a() is generated (c6-cf) it's never called, since it's 
inlined instead at dc-e3:

int i;
void a(){
    i=0;
  c6:   10 92 01 01     sts     0x0101, r1
  ca:   10 92 00 01     sts     0x0100, r1
  ce:   08 95           ret

int main (void)
{    DDRB=255;
  d0:   cf ef           ldi     r28, 0xFF       ; 255
  d2:   d0 e1           ldi     r29, 0x10       ; 16
  d4:   de bf           out     0x3e, r29       ; 62
  d6:   cd bf           out     0x3d, r28       ; 61
  d8:   8f ef           ldi     r24, 0xFF       ; 255
  da:   87 bb           out     0x17, r24       ; 23
  dc:   10 92 01 01     sts     0x0101, r1
  e0:   10 92 00 01     sts     0x0100, r1
      a();
      while(1){PORTB=0;PORTB=255;};
  e4:   18 ba           out     0x18, r1        ; 24
  e6:   88 bb           out     0x18, r24       ; 24
  e8:   18 ba           out     0x18, r1        ; 24
  ea:   88 bb           out     0x18, r24       ; 24
  ec:   fb cf           rjmp    .-10            ; 0xe4


And if I declare a() as static so the compiler knows it's not being called 
from anywhere else, it removes a() entirely, and I get this:

000000c6 <main>:
    i=0;
}

int main (void)
{    DDRB=255;
  c6:   cf ef           ldi     r28, 0xFF       ; 255
  c8:   d0 e1           ldi     r29, 0x10       ; 16
  ca:   de bf           out     0x3e, r29       ; 62
  cc:   cd bf           out     0x3d, r28       ; 61
  ce:   8f ef           ldi     r24, 0xFF       ; 255
  d0:   87 bb           out     0x17, r24       ; 23
  d2:   10 92 01 01     sts     0x0101, r1
  d6:   10 92 00 01     sts     0x0100, r1
      a();
      while(1){PORTB=0;PORTB=255;};
  da:   18 ba           out     0x18, r1        ; 24
  dc:   88 bb           out     0x18, r24       ; 24
  de:   fd cf           rjmp    .-6             ; 0xda

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE


reply via email to

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