Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    cdecl is important because the C programming language uses it, which makes cdecl the most portable/universal of all the calling conventions. Commented Oct 21, 2015 at 4:11
  • 1
    Sorry like the title implies, i am looking for benefits of the calling convention by itself. not by it's sideeffects (like compilers, or cpu being optimized or its ubiquity) Commented Oct 21, 2015 at 4:14
  • There might not be any significant benefits, other than its ubiquity. A calling convention is just an agreement between the caller and the callee. As you've already pointed out in your question, there are many ways to do that successfully, all of which work more or less equally well. Commented Oct 21, 2015 at 4:32
  • there are only so many registers and if the registers are being used for parameter passing, then what happens when some of those registers are needed for the body of a function? Then the registers are saved (on the stack). And when the call stack is of any real depth, you will run out of available registers real fast. The only real difference is: does the caller push/pop the passed parameters to/from the stack (cdecl) or does the callee do that?(stdcal) In general, the stdcal ties up more registers than cdecl, so more of the registers need to be saved/restored by the callee Commented Oct 21, 2015 at 5:19
  • 1
    " then what happens when some of those registers are needed for the body of a function?" Well, then, and only then, you push them. Benefit could be marginal, but the difference is there (in my opinion). You have the chance to choose whether you push or not. Of course that would impose a lot of complexity on the compiler. Commented Oct 21, 2015 at 5:21