flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3, ... 9, 10, 11 Next |
Author |
|
bitRAKE 17 May 2009, 22:15
cdecl has fewer dependencies - can be faster than stdcall. There are often code patterns calling the same function with slightly different parameters. Personally, I use what works best for the code (i.e. hybrids) - maximizing cohesion and minimizing reuse, lol.
Windows 64 combines fastcall and cdecl conventions. The alignment requirement has me using a two level convention throughout - not counting leaf functions. The first level is dictated by Windows, the second level can access parameters from the first level with the call instruction aligning the stack - in contrast the windows unaligning the stack with the call instruction return address. Additionally, the second level doesn't have a shadow/home area. Another trick is to POP the return address into the fifth parameter space, and reuse the shadow stack space locally. I know - unconventional. |
|||
![]() |
|
Azu 03 Jun 2009, 23:28
revolution wrote: For variable argument counts. Else how? The first arg passed tells it how many more there are to expect. There is no reason for it not to use this to clean up the stack. Just another example of bad Windows code. |
|||
![]() |
|
revolution 03 Jun 2009, 23:35
Sure, but remember that the API is written in an HLL (probably C) so variable stack adjustments are not possible since the compiler doesn't support it. And inserting asm code just for that one function is not a sensible solution for HLL programmers targeting multiple systems. Besides, it is not a very critical function, and it is only that one function in the the entire API.
|
|||
![]() |
|
Azu 03 Jun 2009, 23:39
revolution wrote: Sure, but remember that the API is written in an HLL (probably C) so variable stack adjustments are not possible since the compiler doesn't support it. And inserting asm code just for that one function is not a sensible solution for HLL programmers targeting multiple systems. revolution wrote: Besides, it is not a very critical function, and it is only that one function in the the entire API. And if the performance DOESN'T matter.. why even make a new calling standard for this function, when the normal way works fine? The first arg would be the same as it is now.. and there would be a second arg that points to the string of "arguments". Voila, no more need for vararg. This way might actually be faster in some situations, like when you want to re-use it without changing everything. |
|||
![]() |
|
revolution 03 Jun 2009, 23:50
Azu wrote: It trashes the stack though. So obviously it IS taking all the parameters off the stack.. but then at the end doing something like 'add esp,varcount'.. what is the point of this? Azu wrote: And if the performance DOESN'T matter.. why even make a new calling standard for this function, when the normal way works fine? Azu wrote: The first arg would be the same as it is now.. and there would be a second arg that points to the string of "arguments". Voila, no more need for vararg. |
|||
![]() |
|
Azu 03 Jun 2009, 23:55
revolution wrote: Have a look at the code with your disassembler. I think you will find it does not do what you suggest. revolution wrote: But the normal way doesn't "work fine", it is a problem for HLL code. So wvsprintf wasn't written in an HLL? They created it in MASM or something?? |
|||
![]() |
|
revolution 04 Jun 2009, 00:01
Azu wrote: So wvsprintf wasn't written in an HLL? They created it in MASM or something?? |
|||
![]() |
|
Azu 04 Jun 2009, 00:19
revolution wrote:
![]() |
|||
![]() |
|
revolution 04 Jun 2009, 00:31
I said the vararg version is not possible in HLL with auto stack adjustment (stdcall), that is why it is ccall.
The non-vararg version is not a problem. The vararg wraps the non-vararg, like you saw in the disassembler. The non-vararg can adjust the stack (stdcall) but the vararg cannot, it is still a ccall version, it can't adjust the stack. |
|||
![]() |
|
Borsuc 05 Jun 2009, 01:09
revolution wrote: I said the vararg version is not possible in HLL with auto stack adjustment (stdcall), that is why it is ccall. _________________ Previously known as The_Grey_Beast |
|||
![]() |
|
revolution 05 Jun 2009, 01:24
Borsuc: How many HLLs do you know that can directly manipulate the stack register? In asm we can do all those fancy tricks, but not in an HLL.
|
|||
![]() |
|
bitRAKE 05 Jun 2009, 01:28
That wouldn't be STDCALL convention then, Borsuc - it's a good idea none the less to adjust the stack automatically in the case of variable arguments. Simply having the callee manage the array of arguments (passing a pointer) is the usual solution - it is seen throughout the Win APIs.
|
|||
![]() |
|
Borsuc 05 Jun 2009, 02:58
I'm talking about a different calling convention.
You can do in a HLL the same way cdecl does it: by making another convention. Or rather, get rid of cdecl and/or replace it with that method I described. Like maybe call it smartcdecl ![]() _________________ Previously known as The_Grey_Beast |
|||
![]() |
|
revolution 05 Jun 2009, 03:07
To what end? It is only one function anyway. No need to invent a whole new calling convention for it.
|
|||
![]() |
|
f0dder 05 Jun 2009, 05:20
revolution wrote: To what end? It is only one function anyway. No need to invent a whole new calling convention for it. _________________ ![]() |
|||
![]() |
|
revolution 05 Jun 2009, 05:45
Haha, yeah, if your whole code is so reliant upon wsprintf and you complain that you are losing precious time because of an extra add esp,x after each call, then you have written your app very wrongly.
|
|||
![]() |
|
Borsuc 06 Jun 2009, 22:42
You can't fix something fully by ignoring even one small fix.
![]() |
|||
![]() |
|
Azu 07 Jun 2009, 07:56
revolution wrote: To what end? It is only one function anyway. No need to invent a whole new calling convention for it. BTW why does this forum keep forgetting to notify me when a reply is posted? I have to keep re-checking the box over and over.. =/ |
|||
![]() |
|
f0dder 07 Jun 2009, 08:28
Azu wrote:
_________________ ![]() |
|||
![]() |
|
Goto page Previous 1, 2, 3, ... 9, 10, 11 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.