calling convention cheat sheet

cdecl, stdcall, fastcall, c++

Overgeneralization, but may be helpful.

  • cdecl: parameters right to left on the stack, caller places parameters and removes parameters. gcc uses this.
  • stdcall: similar to cdecl, but callee removes function parameters from the stack when finished. Advantage, clean up code doesn’t need to be rewritten for each function. disadvantage, unknown number of parameters are impossible (printf) Microsoft compilers use this
  • fastcall stdcall, but uses two parameters in cpu registers (ecx and then edx)
  • c++ ‘this’ is passed in ecx (ms visual c++) or passed as first parameter (g++)

More handy is this: http://en.wikipedia.org/wiki/X86_calling_conventions
awesome

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: