> If you declare a string and then use it as an initializer for an array of 
> characters, the compiler will arrange for the string to be stored somewhere 
> and then copy it to the array to perform the initialization.  Should you 
> need the string "abd" elsewhere in your program, the same copy might be 
> used.

This makes a lot of sense, only that I do not observe the string
actually being copied to RAM:

char test1[] = "abd";
if (test1[0] == 'a') DO_SOMETHING;

DO_SOMETHING doesn't happen.  I see that the produced assembly

  char test1[] = "abd";
lds     r24, 0x0100
lds     r25, 0x0101
lds     r26, 0x0102
lds     r27, 0x0103
std     Y+15, r24       ; 0x0f
std     Y+16, r25       ; 0x10
std     Y+17, r26       ; 0x11
std     Y+18, r27       ; 0x12

loads bytes from SRAM, which should be abc\0 for the string to get
initialized in data segment, but I'm getting 0xff at runtime.

Please advise.
Zoran




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to