skyking wrote:
Thats not the way it's done. First the number of parameters isn't needed since the caller knows how many arguments it has pushed and how many it have to remove - the called function however uses other means to determine the number of arguments to be examined (printf for example uses the format string to determine that).
The number of parameters is NOT needed? If you are following a derivation of StdCall for Variable Arguments where parameters are pushed onto the stack from right to the left, the number of parameters should be the last argument that is passed onto the stack. The reason is that with StdCall, the Caller procedure DOES NOT remove the parameters from the stack. That's CDecl. In StdCall, the CALLEE removes the parameters. The Callee therefore must know how many parameters to remove from the stack by adjusting ESP since you can't have a GPR or a memory reference with the RET instruction. So you will have to increase the ESP.
skyking wrote:
And the order is first parameter last - this way the first parameter will be directly under the return address (for intel architectur).
Again, I don't remember talking about CDecl at all. I was talking about StdCall and Variable arguments that can be pushed onto the stack using a calling convention similar to StdCall.
Craze Frog wrote:Sorry, but have obviously no clue what you are talking about. Instead of arguing, why don't you go an look at some actual compiler output? I wouldn't have said these things if I didn't have tested it, I suggest you follow the same policy.
I would never follow the "Same policy" that you have followed since your statements are utterly wrong. You NEVER pass an 80-bit long value onto the stack using 80-bits of the stack space. You ALWAYS pass the pointer to that data structure. I suggest YOU debug some programs and see what I mean. When you pass floating point values and etc amongst normal integral values, an optimized and a sane compiler usually passes the integral values (poiners, etc) using the calling convention and floating points in ST0 to ST7 so that the function will not have to maintain those floating point values from the stack to maintain stack and parameter size consistency.
Craze Frog wrote:That line is WRONG for gcc and vcc. Even for Delphi it's wrong order...
Do you see me discussing the order of these parameters in Delphi? Again to refresh your mind,
My Web Site wrote:If there are more than three parameters, the first three should be placed inside EAX, ECX and EDX registers and the rest should be pushed onto the stack from left to right.
You'll win 2000 USD if you could find me discussing the order in which these parameters are passed to those GPRs
Craze Frog wrote:You can't pick your own style if you want to interface with compiled code.
Do you see me discussing interfacing with compiled codes about the FastCall calling convention? The Register calling convention is what Delphi uses for example. First parameter (from the left) in EAX, then EDX and then ECX. Why do you think you can't pick your own style? If you are writing an Operating System, you could have a compiler that follows your operating system's default calling convention. Like what Linux does when passing parameters into GPRs. There are no rules to that.
I suggest you don't suggest me what to suggest to people