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

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

[avr-gcc-list] avr-libc deprecation/optimisation question


From: Ewout Boks
Subject: [avr-gcc-list] avr-libc deprecation/optimisation question
Date: Sat, 11 Oct 2003 13:08:54 +0200
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20030703

Hi all,

I recently installed the latest freebsd port for avr-libc and noticed
that the usage of the inb() and outb() functions was declared
deprecated, and that the  direct access of I/O registers  is now the
preferred way. Out of curiosity I decided to see what the compiler does
with this.

When I compile the following code:

         PORTD = (1<<5);

For this C instruction I get from avr-objdump this result:

28:   80 e2           ldi     r24, 0x20       ; 32
2a:   80 93 32 00     sts     0x0032, r24

so the compiler chooses the sts instruction to load the data in the SRAM
 mapping of the registers. This is of course perfectly acceptable.

When I look at the instruction set documents, I see that the sts
instruction needs 2 words and 2 cycles to execute. The out instruction,
, which performs exactly the same task, only needs 1 word and 1 cycle.
If coding in assembly, I would choose that instruction.

Does anyone know why the more expensive (in terms of prog space and
execution time) sts instruction was chosen for direct mapping of an I/O
register? Does the compiler know the difference between I/O and other
registers?


Ewout





reply via email to

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