17 Mixing C and Assembly Code

Note: The examples presented in this section may not compile or assemble on all devices; however, they are illustrative of the concepts being presented.

This section describes how to use assembly language and C/C++ modules together. It gives examples of using C/C++ variables and functions in assembly code and examples of using assembly language variables and functions in C/C++.

Note:

Calling C++ from assembly function is complex: C++ member functions have an implicit this pointer as an argument and C++ functions have their names mangled.

Calling assembly functions from C++ is easier: Assembly functions will require that their names be prototyped with extern "C".

Items discussed are: