11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Efficient coding forembedded applicationsFor embedded systems, the size of the generated code and data is veryimportant, because using smaller external memory or on-chip memory cansignificantly decrease the cost and power consumption of a system.The topics discussed are:●●●●Selecting data typesControlling data and function placement in memoryControlling compiler optimizationsWriting efficient code.As a part of this, the chapter also demonstrates some of the more commonmistakes and how to avoid them, and gives a catalog of good codingtechniques.Selecting data typesFor efficient treatment of data, you should consider the data types used and the mostefficient placement of the variables.USING EFFICIENT DATA TYPESThe data types you use should be considered carefully, because this can have a largeimpact on code size and code speed.●●●●Use small data types.Try to avoid 64-bit data types, such as double and long long.Bitfields with sizes other than 1 bit should be avoided because they will result ininefficient code compared to bit operations.Using floating-point types is very inefficient, both in terms of code size andexecution speed. If possible, consider using integer operations instead.Part 1. Using the compiler 113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!