SLAU132V October 2004 – February 2020
Functions defined in C++ that will be called from assembly should be defined as extern "C" in the C++ file. Functions defined in assembly that will be called from C++ must be prototyped as extern "C" in C++.
Example 2 illustrates a C++ function called main, which calls an assembly language function called asmfunc, Example 3. The asmfunc function takes its single argument, adds it to the C++ global variable called gvar, and returns the result.