x64 Assembly Tutorial 27: Calling C++ from ASM

In this, the 27th, tutorial, we will looking at the "C" calling convention from the Caller's point of view. This is not Assembly. It's the meaning of 'extern "C"' that we've been placing at the start of our procedures. Parameters used to be pushed onto the stack from right to left but nowadays the first four are passed by the registers RCX, RDX, R8 and R9 respectively. Stack space is still preserved for these parameters in the form of "Shadow Space". Shadow space is the space that the first four parameters would have occupied had they not been passed by registers. Once your in Assembly calling other procedures also written in Assembly you can do whatever you like including passing all parameters via whichever registers you want. This calling convention is to communicate with C++! Nearing the end of this tutorial I say 'this is exactly how the stack will look when we get it in ASM', please watch the next tutorial for a full explanation but I forgot that there will also be a return address on the stack!