Calling conventions
-
What is the difference between C and Pascal calling convention ? I have heard that pascal calling convention saves bytes - Is it true ? IF true how ?
The C calling convention puts the parameters on the stack from right to left, this allows the C calling convention to have an limitless parameter list like in the printf function. The caller pops parameters from the stack. The pascal calling convention is obsolete in WIN32, but it passes its parameters from left to right. I am not sure, but I believe that the callee pops parameters from the stack frame.
-
What is the difference between C and Pascal calling convention ? I have heard that pascal calling convention saves bytes - Is it true ? IF true how ?
I wrote a little article on calling conventions. However, you won't find anything about Pascal calling convention. It was replaced by stdcall in Win32 I vote pro drink :beer:
-
The C calling convention puts the parameters on the stack from right to left, this allows the C calling convention to have an limitless parameter list like in the printf function. The caller pops parameters from the stack. The pascal calling convention is obsolete in WIN32, but it passes its parameters from left to right. I am not sure, but I believe that the callee pops parameters from the stack frame.
The pascal (stdcall) calling convention is not obsolete in Win32. Most of the Win32 API uses it. Is has various macros to describe it such as WINAPI, CALLBACK, APIPRIVATE, PASCAL, and IMAGEAPI. It is used for two reasons : first so that multiple programming languages can be supported and second because M$ claims that it is slightly more efficient. :rolleyes: Whatever. You are right that the callee fixes the stack. This is done by adding the number of bytes that were pushed back to ESP. BTW: I actually do have something that resembles a life but I have spent lots of time reading .cod listings. :)