Hello, more noobisms your way, I'm afraid. I can't find an explanation elsewhere why there should be a difference in the generated code for string vs. array-of-chars initializers. Compiling the following code:
/* ... */ int main() { char test1[] = "abd"; char test2[] = { 'a', 'b', 'd', '\0' }; /* ... */ } using avr-gcc 4.3.2, invoked with avr-gcc -g -mmcu=atmega168 main.c -o main.o -lm and disassembled with avr-objdump -S main.o shows this: char test1[] = "abd"; 8c0: 80 91 00 01 lds r24, 0x0100 8c4: 90 91 01 01 lds r25, 0x0101 8c8: a0 91 02 01 lds r26, 0x0102 8cc: b0 91 03 01 lds r27, 0x0103 8d0: 8f 87 std Y+15, r24 ; 0x0f 8d2: 98 8b std Y+16, r25 ; 0x10 8d4: a9 8b std Y+17, r26 ; 0x11 8d6: ba 8b std Y+18, r27 ; 0x12 char test2[] = { 'a', 'b', 'd', '\0' }; 8d8: 81 e6 ldi r24, 0x61 ; 97 8da: 8b 8b std Y+19, r24 ; 0x13 8dc: 82 e6 ldi r24, 0x62 ; 98 8de: 8c 8b std Y+20, r24 ; 0x14 8e0: 83 e6 ldi r24, 0x64 ; 100 8e2: 8d 8b std Y+21, r24 ; 0x15 8e4: 1e 8a std Y+22, r1 ; 0x16 Why the difference? Thanks, Zoran _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list