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.

Calling assembler routines from <strong>C++</strong>●●●The global variablesThe function parametersHow to create space on the stack (auto variables)● Call frame information (CFI).The CFI directives describe the call frame information needed by the Call Stack windowin the <strong>IAR</strong> C-SPY Debugger.Calling assembler routines from <strong>C++</strong>The C calling convention does not apply to <strong>C++</strong> functions. Most importantly, a functionname is not sufficient to identify a <strong>C++</strong> function. The scope and the type of the functionare also required to guarantee type-safe linkage, and to resolve overloading.Another difference is that non-static member functions get an extra, hidden argument,the this pointer.However, when using C linkage, the calling convention conforms to the C callingconvention. An assembler routine may therefore be called from <strong>C++</strong> when declared inthe following manner:extern "C"{int my_routine(int x);}Memory access layout of non-PODs (“plain old data structures”) is not defined, and maychange between compiler versions. Therefore, we do not recommend that you accessnon-PODs from assembler routines.To achieve the equivalent to a non-static member function, the implicit this pointer hasto be made explicit:class X;extern "C"{void doit(X *ptr, int arg);}88<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!