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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Calling conventionCHOOSING A CALLING CONVENTIONThe compiler supports two calling conventions:●The Version1 calling convention is used by version 1.x, 2.x, and 3.x of the compiler● The Version2 calling convention was introduced with version 4.x of the compiler. Itis more efficient than the Version1 calling convention.You can explicitly specify the calling convention when you declare and define functions.However, normally this is not needed, unless the function is written in assembler.For old routines written in assembler and that use the Version1 calling convention, thethe keyword __cc_version1 function attribute should be used, for example:extern __cc_version1 void doit(int arg);New routines written in assembler should be declared using the keyword__cc_version2. This ensures that they will be called using the Version2 callingconvention if new calling conventions are introduced in future compilers.Hints for a quick introduction to the calling conventionsBoth calling conventions are complex and if you intend to use any of them for yourassembler routines, you should create a list file and see how the compiler assigns thedifferent parameters to the available registers. For an example, see Creating skeletoncode, page 86.If you intend to use both of the calling conventions, you should also specify a value tothe runtime model attribute __rt_version using the RTMODEL assembler directive:RTMODEL "__rt_version"="value"The parameter value should have the same value as the one used internally by thecompiler. For information about what value to use, see the generated list file. If thecalling convention changes in future compiler versions, the runtime model value usedinternally by the compiler will also change. Using this method gives a moduleconsistency check as the linker will produce an error if there is a mismatch between thevalues.For more information about checking module consistency, see Checking moduleconsistency, page 71.FUNCTION DECLARATIONSIn C, a function must be declared in order for the compiler to know how to call it. Adeclaration could look as follows:int a_function(int first, char * second);90<strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>Reference Guide

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

Saved successfully!

Ooh no, something went wrong!