SLAU132V October 2004 – February 2020
.global asmfunc
.global gvar
asmfunc:
MOV &gvar,R11
ADD R11,R12
RET
In the C++ program in Example 2, the extern "C" declaration tells the compiler to use C naming conventions (i.e., no name mangling). When the linker resolves the .global asmfunc reference, the corresponding definition in the assembly file will match.
The parameter var is passed in R12, and the result is returned in R12.