??? 03/16/05 07:59 Modified: 03/16/05 07:59 Read: times |
#89761 - Great suggestions Responding to: ???'s previous message |
Massimo Battiston said:
Hi,
j think the suggestion of using sdcc is a good idea for a student. Anyway if you want to continue using Keil j can suggest : - Use a higher optimisation level. - Use the small memory model - Set the "code Rom Size" to "small". - Enable the "global register coloring" option. This will increase the compile time but usually save some bytes of code. - If you use pointers try to use memory specific pointers like : char data* Pchar. This will help a lot but however you loose flexibility. - Try to use variables of 8 bit lenght maximun (remember 8051 is a 8 bit microcontroller). However the effect of the solutions depends on your application, and how the code is written. Best regards. Massimo. These are all excellent suggestions. Of course it is also worth mentioning that use of large standard library routines (i.e., printf()) will add signficantly to code size as well. The bottom line is that a lot of constructs that are perfectly reasonable on a PC are remarkably inefficient on an 8051 (i.e., non-memory specific pointers). Keil lets us use these constructs both for convenience and compatibility, but that does not necessarily make them appropriate. Effectively programming an 8051 in C requires not only knowledge of C, but also a good understanding of the underlying architecture and how the C code being written maps on to it. Chapter 3 of the "Getting Started with uVision2" manual nicely summarizes some of the key issues discusssed here. It is definitely worthwhile reading for anyone that is new to the toolchain. --Sasha Jevtic |