[Top][All Lists]

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

Re: [avr-gcc-list] Compiler generates much overhead and "stupid" code so

From: Jeff Epler
Subject: Re: [avr-gcc-list] Compiler generates much overhead and "stupid" code sometimes....
Date: Thu, 28 Apr 2005 10:48:13 -0500
User-agent: Mutt/1.4.1i

On Thu, Apr 28, 2005 at 04:16:57PM +0200, address@hidden wrote:
> 1.question: why the files differ?

Because often a special case (such as "clr r25") is really a particular
usage of a more general instruction ("eor r25, r25").  I think the "lss"
file is produced by disassembly, and it doesn't appear to use the
special-case names for instructions.  You'll soon learn to recognize the
pairs of special/generic instructions.  Not that it wouldn't be nicer if
avr-objdump recognized the special cases, it would take that much more
burden off the programmer. (But then a programmer who wrote 'eor r25,
r25' might complain that the disassembler showed him a different
instruction called 'clr'...)

> 2.question: why the compiler needs 10 instructions if optimize is off?
>               it seems, the compiler shifts a constant until Bit 6 is set....
>               with opt = 2, the compiler generates 3 assembler 
> instructions.....

Turn on the optimizer if you want the code to be optimized.  Without
optimization (or with -O0), the compiler will write a very literal
interpretation of the code you write.  For instance,
    1 << TOV2
will be executed by storing the value "1" in an int-sized location, then
shifting it right TOV2 counts.  This is very verbose in AVR code.

I generally use "-Os" (optimize for size) when building avr code.


Attachment: pgp6wDtVqPT1c.pgp
Description: PGP signature

reply via email to

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