??? 07/15/09 22:35 Read: times |
#167378 - Getting the Least Out of Your C Compiler Responding to: ???'s previous message |
A general article (not specific to any particular compiler or target) on writing efficient 'C' code:
Getting the Least Out of Your C Compiler
Class #508, Embedded Systems Conference San Francisco 2001 Jakob Engblom IAR Systems Box 23051 SE-750 23 Uppsala Sweden Using only the internal program and data memory of a microcontroller can save large costs in embedded systems design. This requires, however, that the program fits into the memory — which is not always easy to accomplish. This article discusses how to help a modern, highly optimizing C compiler generate small code, while maintaining the portability and readability advantages offered by C. In order to facilitate an understanding of what a compiler likes and does not like, we will give an inside view on how a compiler operates. Many established truths and tricks are invalidated when using modern compilers. We will demonstrate some of the more common mistakes and how to avoid them, and give a catalog of good coding techniques. An important conclusion is that code that is easy for a human to understand is usually also compiler friendly, contrary to hacker tradition. http://user.it.uu.se/~jakob/pu...f-2001.pdf For specific advice related to Keil C51, see: http://www.keil.com/support/m...c51_xc.htm |