[En-Nut-Discussion] Byte select macros

Bernard Fouché bernard.fouche at kuantic.com
Tue Nov 23 15:33:09 CET 2010


changing to:

extern unsigned char res[];

gives, with -Os:

00000000<foo>:
    0:	e0 91 00 00 	lds	r30, 0x0000
    4:	f0 91 00 00 	lds	r31, 0x0000
    8:	80 81       	ld	r24, Z
    a:	80 93 00 00 	sts	0x0000, r24
    e:	81 81       	ldd	r24, Z+1	; 0x01
   10:	80 93 00 00 	sts	0x0000, r24
   14:	82 81       	ldd	r24, Z+2	; 0x02
   16:	80 93 00 00 	sts	0x0000, r24
   1a:	83 81       	ldd	r24, Z+3	; 0x03
   1c:	80 93 00 00 	sts	0x0000, r24
   20:	08 95       	ret

There are many bug reports about missed optimizations for avr-gcc 4.3.0. It seems that 4.6.0 could be better and it has also link time optimization.

However I did not experiment with versions later that 4.3.0.

	Bernard

Le 22/11/2010 23:37, Uwe Bonnes a écrit :
> extern unsigned char *res;
> extern unsigned short *input;
>
> void
> foo()
> {
>          res[0] = input[0]&  0xff;
>          res[1] = input[0]>>  8;
>          res[2] = input[1]&  0xff;
>          res[3] = input[1]>>  8;
> }
> ==
> with
> /tmp>  avr-gcc -Os -Wall -c test.c
> /tmp>  avr-objdump -S test.o | less
>
> 8-(
>



More information about the En-Nut-Discussion mailing list