I know that when calling a non-static member function of an object in c++, the this pointer is passed in ecx register. What about static functions, as there is no this pointer, does the compiler use ecx register to pass one of the regular parameters in this case?
Edit – I’m talking about the cdecl calling convention here.
What
ecx(or any other register) is used for when calling functions depends on the calling convention.For instance, consider the C++ code
Compiling this with Microsoft Visual Studio 2010 (64bit) via
And then dumping the assembly via
Gives this for the
gfunction:Notice how the first call to the static
S::fmethod has the first argment (3) passed inecxand the second argment (4) inedx. So the answer to your question is:Yes. For this particular compiler,
ecxis used to pass one of the parameters in a static function call.