flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3 ... 5, 6, 7 ... 9, 10, 11 Next |
Author |
|
arigity 08 Jun 2009, 14:50
Azu wrote: Okay, so in some situations the amount of unneeded code is less then in others. It is still unneeded even in this situation. And in the loops and stuff it is even worse, which is where it matters most.. if it is done like this (which is frequently is) it may save size and speed over stdcall. |
|||
![]() |
|
Azu 08 Jun 2009, 14:51
LocoDelAssembly wrote:
LocoDelAssembly wrote: FYI, in an HLL (something you supposedly don't care) it would be just this: LocoDelAssembly wrote:
arigity wrote:
Am I going to have to completely recreate the whole damn function and publish it and benchmarks for it before you'll believe??? ![]() Why? Just take a quick look at how it is being done right now, you will see right away there is no reason it wouldn't work better pure stdcall non-wrapper way.. it knows the args passed due to the format string.. and there is no reason for it to parse them out of order.. and even if there was could just use internal counter to keep track of how many, instead of popping them as they are used, and do add esp thing inside function at least.. P.S. since you guys like random niche cases which will never be really used, I will make one to; pusha call StdStyleWsprintf Just make sure eax points to format string that wants 7 values and what do you know ![]() This can print all register except eax.. your niche example only print ebp and esp! And mine would be with normal calling standard.. yours is NOT stdcall... stdcall does not have weird "leave, ret" instructions at end! Last edited by Azu on 08 Jun 2009, 15:12; edited 1 time in total |
|||
![]() |
|
LocoDelAssembly 08 Jun 2009, 15:11
Preallocation example for loop using printf
Just to make some points: * I don't care about the origins of cdecl, I know of them but my interest in having it for printf is not for plain desire to adhere to standards. * When using varargs, cdecl is faster than stdcall (the variant that would support varargs). * The code using printf would be sightly smaller in some situations and of the same size in others if stdcall (with varargs support) were used, but at the expense of extra execution time. |
|||
![]() |
|
Azu 08 Jun 2009, 15:15
LocoDelAssembly wrote: Preallocation example for loop using printf I mean real stdcall version, where they are passed in stack, and function cleans them up ![]() No allocation would be needed within the function. You would obviously need pointer to allocated space for it to output to though, since that is what this function does.. it prints text into a buffer.. and no standard can effect this. Except maybe having it return the string in the stack, but that would be really really REALLY bad =/ |
|||
![]() |
|
LocoDelAssembly 08 Jun 2009, 15:19
Sorry, where I'm talking about wvsprintf?
|
|||
![]() |
|
Azu 08 Jun 2009, 15:24
LocoDelAssembly wrote: cdecl is faster than stdcall (the variant that would support varargs). Program code Code: push arg1 push arg2 push arg3 call func add esp,12 vs Code: push arg1 push arg2 push arg3 call func and Library code Code: add ebp,4 mov eax,[ebp] Code: pop eax Would be the main differences between the cdecl and true stdcall ways, and surely the latter are faster/smaller? Maybe not for functions that access them out of order, but wsprintf doesn't, and is the only cdecl Windows function, since C++ function != Windows function. Last edited by Azu on 08 Jun 2009, 15:39; edited 1 time in total |
|||
![]() |
|
arigity 08 Jun 2009, 15:38
Azu wrote:
curious, what library did you grab that code from? stdcall pops the arguments off at the end (like a calling convention should) by retn xx |
|||
![]() |
|
Azu 08 Jun 2009, 15:42
arigity wrote:
Last edited by Azu on 08 Jun 2009, 15:43; edited 2 times in total |
|||
![]() |
|
LocoDelAssembly 08 Jun 2009, 15:42
Where do you see varargs there, which is the only case all but you are considering cdecl better over stdcall (with the appropiate modifications to support varargs since standard stdcall doesn't support them)?
|
|||
![]() |
|
arigity 08 Jun 2009, 15:43
the pop is usually to restore ebp at the end which was saved at the start.....
|
|||
![]() |
|
Azu 08 Jun 2009, 15:45
LocoDelAssembly wrote: Where do you see varargs there, which is the only case all but you are considering cdecl better over stdcall (with the appropiate modifications to support varargs since standard stdcall doesn't support them)? arigity wrote: the pop is usually to restore ebp at the end which was saved at the start..... |
|||
![]() |
|
revolution 08 Jun 2009, 15:51
Azu wrote: So why go out of their way to implement cdecl for just this one when they could do it stdcall way instead and have it more efficient? And the efficiency is still in question. |
|||
![]() |
|
Azu 08 Jun 2009, 15:54
revolution wrote: HLL can't do it ![]() |
|||
![]() |
|
revolution 08 Jun 2009, 16:00
Azu wrote: HLLs can call stdcall functions, and there is macro in FASM that works the same way (is called stdcall, fittingly), and I can use it to call functions that are like this, so HLL should be able to also.. i Azu wrote: if not, well, HLL sucks. |
|||
![]() |
|
arigity 08 Jun 2009, 16:02
Azu wrote: ebp shouldn't even be needed for this function. It is a artifact of the fixed arg count functions, not good for one like wsprintf. ebp is used for local variables too.... |
|||
![]() |
|
Azu 08 Jun 2009, 16:02
revolution wrote:
revolution wrote:
arigity wrote:
|
|||
![]() |
|
revolution 08 Jun 2009, 16:06
Azu wrote: The same way it passes a "fixed" number of arguments. It shouldn't even be able to tell whether it is a "fixed" number or "variable" number, it is semantically called the same way. Code: Sleep(1,2,3,4); |
|||
![]() |
|
arigity 08 Jun 2009, 16:07
Azu wrote: The same way it passes a "fixed" number of arguments. It shouldn't even be able to tell whether it is a "fixed" number or "variable" number, it is semantically called the same way. stdcall uses retn const a the end of a function it cannot use vararg, it does not work that way. what you suggest puts near-retarded limitations, is ridiculously hard to implement, and almost completely removes any use for the stack ~at all~ |
|||
![]() |
|
LocoDelAssembly 08 Jun 2009, 16:07
If they really had to implement cdecl themselves can't be know, for instance, perhaps they just used the built-in functionality of the C compiler they probably used to code that function? cdecl exists way before Windows.
Also, I don't see why cdecl should be avoided for wsprintf, I don't care if it is for support HLLs or not, it just work good for varargs. Making wsprintf take care of ESP adjustment would make the code less efficient (speed-wise) and the fmt string would have to reference exactly the same amount of parameters that have been passed (currently you can reference less without relying on anything non standard). |
|||
![]() |
|
Goto page Previous 1, 2, 3 ... 5, 6, 7 ... 9, 10, 11 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.