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.

Assembler language interfaceIt is possible to “wrap” the call to the assembler routine in a member function. Using aninline member function removes the overhead of the extra call—provided that functioninlining is enabled:class X{public:inline void doit(int arg) { ::doit(this, arg); }};Note: Support for <strong>C++</strong> names from assembler code is extremely limited. This meansthat:● Assembler list files resulting from compiling <strong>C++</strong> files cannot, in general, be passedthrough the assembler.It is not possible to refer to or define <strong>C++</strong> functions that do not have C linkage inassembler.Calling conventionA calling convention is the way a function in a program calls another function. Thecompiler handles this automatically, but, if a function is written in assembler language,you must know where and how its parameters can be found, how to return to the programlocation from where it was called, and how to return the resulting value.It is also important to know which registers an assembler-level routine must preserve. Ifthe program preserves too many registers, the program might be ineffective. If itpreserves too few registers, the result would be an incorrect program.The <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong> provides two calling conventions—Version1 andVersion2. This section describes the calling conventions used by the <strong>MSP430</strong> <strong>IAR</strong>C/<strong>C++</strong> <strong>Compiler</strong>. The following items are examined:●●●●●●●Choosing a calling conventionFunction declarationsC and <strong>C++</strong> linkagePreserved versus scratch registersFunction entranceFunction exitReturn address handling.At the end of the section, some examples are shown to describe the calling conventionin practice.Part 1. Using the compiler89

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

Saved successfully!

Ooh no, something went wrong!