??? 03/16/05 16:55 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#89783 - C limitations Responding to: ???'s previous message |
Many others have have given excellent posts on the limitations of C in general and some on the specific problems on an 8 bit micro. I would just like to add that most C compilers pass parameters to functions on the stack and also use the stack for variables that are local to a function. Most 8051 C compilers do not do this because of the very small size of stack available on the 8051. Many use the registers to pass parameters but this causes problems as soon as you nest subroutines. Some compilers even look at the call sequence of your code and try to minimise the number of registers used by reusing ones that they reckon will not overlap in execution.
All this means is that once the code has been optimised, if you make a small change to the call sequence, the code timing could change a lot. One way to minimise this is to pass as few parameters as possible and use global variables wherever possible. This will certainly reduce code size and speed up execution but goes against the software gurus ideas of code modularity and managing the scope of variables. Of course, in assembler none of this is a problem. Ian |