Hello all, I am playing with strings in ROM, make an array and return pointer to the string in array. The C code is below. After I compile it, I see in the code that there is FIXME for multiplication (actual SDCC snapshot). Does it affect anything ?
The reason is that the "array" code is shorter (44 bytes compared to 70 bytes of "if" code) and more readable as well. But the question is if the generated code is correct (IMHO it is, even with FIXME, but only for first 256bytes of memory). Thank you, Vasek // SDCC test #include <pic18fregs.h> #define byte unsigned char const code byte string0[] = { 't','e','s','t','0',}; const code byte string1[] = { 't','e','s','t','1',}; const code byte string2[] = { 't','e','s','t','2',}; const code byte *stringArray[] = { (const code byte*) string0, (const code byte*) string1, (const code byte*) string2 }; volatile code byte *outPtr; volatile byte index; void main( void) { if ( index == 0) { outPtr = (code byte *) (&string0); } else if ( index == 1) { outPtr = (code byte *) (&string1); } else { outPtr = (code byte *) (&string2); } outPtr = (code byte *) &(stringArray + index); } ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user