flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
Melissa 27 Feb 2018, 23:52
Well, variadic function calling convention is compiler specific, I think.
|
|||
![]() |
|
DimonSoft 28 Feb 2018, 10:05
Melissa wrote: Well, variadic function calling convention is compiler specific, I think. But cdecl is the common one, for historical reasons. There’re two things that should be true for a calling convention to allow easy parameter access in variadic functions: access to the parameters should be uniform and address/location of the parameter that defines the actual parameter count (say, format string in printf) should not change with the change of the parameter count. Definitely thousands of conventions can be invented that pass the requirements. |
|||
![]() |
|
Furs 28 Feb 2018, 15:44
If the caller behaves, there's no reason to have it pop the stack.
You can pop the stack from the callee even with variadic functions, as long as no "extra parameters" are passed (depending on the function, e.g. with printf, more than the amount of % specifiers). Though you'll need a bit of hackery to pull it off in the callee. ![]() |
|||
![]() |
|
DimonSoft 28 Feb 2018, 15:55
Furs wrote: If the caller behaves, there's no reason to have it pop the stack. That wouldn’t be a cool trick then. One-operand RET is what makes it cool, other stuff would not differ much on x86 from using POPs to access parameters (from the convenience point of view). I mean, we can also sort arrays by randomly mixing the elements and checking if it got sorted but we don’t. Style points rule ![]() |
|||
![]() |
|
rugxulo 28 Feb 2018, 21:51
Melissa wrote: Well, variadic function calling convention is compiler specific, I think. AFAIK, old K&R C required variadic functions to rely on assembly. But with ANSI C (C89), you finally got stdarg.h (but you can also find varargs.h in some places, albeit not recommended anymore). I heard once that functions in "standard" C were limited, portably, to only 32 parameters. A quick search shows someone saying it's 31 for C89 but 127 for C99. (Of course, certain implementations may give more.) |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.