Search results
Results From The WOW.Com Content Network
The difference is the addition of the this pointer, which is pushed onto the stack last, as if it were the first parameter in the function prototype. On the Microsoft Visual C++ compiler, the this pointer is passed in ECX and it is the callee that cleans the stack, mirroring the stdcall convention used in C for this compiler and in Windows API ...
For example, on 32-bit Windows, operating system calls have the stdcall calling convention, whereas many C programs that run there use the cdecl calling convention. To accommodate these differences in calling convention, compilers often permit keywords that specify the calling convention for a given function.
In the stdcall and fastcall mangling schemes, the function is encoded as _name@X and @name@X respectively, where X is the number of bytes, in decimal, of the argument(s) in the parameter list (including those passed in registers, for fastcall). In the case of cdecl, the function name is merely prefixed by an underscore.
cdecl and stdcall names are case-senstive. pascal names are not. While technically not part of the calling convention, there is the greater good to consider. If case-sensitivity is included, it would help those reading this article who are trying to resolve calling convention related problems.
One of the most important difference between C and Pascal is the way they handle the parameters on stack during a subroutine call : This is called the calling convention : PASCAL-style parameters are pushed on the stack in left-to-right order. The STDCALL calling convention of C pushes the parameters on the stack in right-to-left order.
Several possible prologues can be written, resulting in slightly different stack configuration. These differences are acceptable, as long as the programmer or compiler uses the stack in the correct way inside the function. As an example, here is a typical x86 assembly language function prologue as produced by the GCC
Many of the differentiators can appear within the same OS: far pascal is differs from cdecl in many ways. So perhaps an appropriate way forward is have additional bullets in the existing list, along the lines of: Which registers get saved buy the caller, and which saved by the callee.
What links here; Related changes; Upload file; Special pages; Permanent link; Page information; Cite this page; Get shortened URL; Download QR code