From: Raphael N. <rn...@we...> - 2009-11-05 23:24:21
|
Hi, > Program displays just T[glyph/rand char][glyph/rand char][glyph/rand > char] [glyph/rand char]. > > Why is this happening and how can I prevent it? Thanks. You perform pointer arithmetics on generic pointers (*(s+1)), and thus triggered a compiler bug which assigned only the lower 2 byte (of the 3 byte generic pointer) to the (temporary) result. The subsequent dereference of course evaluated all three bytes of the pointer -- but as the MSB was uninitialized, we accessed random memory locations, causing your program to display [glyph/rand char] for s+1, s+2, and s+3. You can prevent it by (a) updating to sdcc 2.9.4, >= r5568 (either using a snapshot or the svn head) or (b) by avoiding generic pointers, replacing them with __data pointers: unsigned char text[10]; void LCD_String(__data unsigned char *s) { LCD_Char(*s); LCD_Char(*(s+1)); LCD_Char(*(s+2)); LCD_Char(*(s+3)); } Thank you for reporting this bug. Raphael |