To learn how to intermix Assembly Language and C/C++. WARNING: This is going to be an OS and IDE specific section. What will work on Linux will not work the same in Windows. This also includes differences between 32 bits and 64 bits!
Remember to refer to calling_conventions by Agner Fog, as on page 17 in the pdf file contains a listing of register/parameter ordering based on different OSes and whether we are dealing with 32 bits or 64 bit OSes as well.
When compiling and linking C++ source code and Assembly Source code, caution should be noted with Visual Studio that with 64 bit C++, there is no support for inline Assembly Language. It is in my professional opinion that this is a good idea not to intermix Assembly Language source code with a high level language source code, as program readability can turn out quite poor. Better practice is to seperate high level language code from low level language code into seperate files, and let the linker do all the heavy lifting for us! Also, in regards to Visual Studio, one must make sure that MASM is set in the Build Customizations BEFORE writing a single line of code in either C/C++ or Assembly Language to ensure that the project Custom Build Step will include compiling the Assembly code. If not, Visual Studio will do nothing to the .asm file and you will be greeted with an 'unresolved reference' error.
Next consideration, which is OS independent, but some arm twisting of the compiler we have to do: in the C/C++ program, make sure to use
extern "C" <your function prototype here>
as using the "C" will FORCE the C/C++ compiler to NOT name mangle the function name of our function in Assembly Language!
More on this topic will be added at a future date!
. . . . . . . . . ( end of section Assembly Language and C/C++) <<Contents | Index>>