| ??? 05/21/03 00:05 Read: times |
#46182 - RE: SDCC, large mem model, code inefficiency Responding to: ???'s previous message |
Keith:
Your method of programming the variable is what gives you the code you got. By making the message[] variable an array that was inside the procedure but was initialized from a constant string says that you wanted a string variable that could be changed inside the routine. You could avoid the messy initialization code in a couple of ways: Method 1. If the message[] variable did not really need to be changable in the routine maybe you could instead in the place where you used message[], such as: sprintf(buffer,"++%s++",&message[0]); ...you could code sprintf(buffer,"++%s++","Welcomen"); Method 2. You could instead use a pointer instead of the message[] array. If you coded.. unsigned char *msg_prt="Welcomen"; ...the resulting initialization would simply be a pointer setting to the location of the compiler placed fixed text string. You could even make the code more efficient by declaring the pointer to be a pointer to a "code" space string as.. unsigned char code *msg_prt="Welcomen"; Method 3. You could initialize the string yourself using a library function. The library function is most likely an efficient loop at least. Thus you could write.. Unsigned char message[15];
strcpy(message,"Welcomen");
I guess one reason we use C is to avoid having to write junk like this stuff by hand in assembler. On the other hand the C programmer, particularly on the 8051 needs to study carefully "how" you write programs to avoid really messy assember from being generated by the C compiler. Good Luck |
| Topic | Author | Date |
| SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
| RE: SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
| RE: SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
| RE: SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
| RE: SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
| RE: Compiler hacking? VFM? | 01/01/70 00:00 | |
| RE: SDCC, large mem model, code inefficiency | 01/01/70 00:00 | |
Thanks for all the responses... | 01/01/70 00:00 |



