flat assembler
Message board for the users of flat assembler.
Index
> Main > Registers vs. stack in calling convention |
Author |
|
beppe85 10 Jan 2005, 15:45
Passing arguments on stack is too slow for small, lightweight routines, but for non-leaves routines they perform pretty well. So I made an attempt to put in numbers its (in)efficiency.
I provide two macroes, regcall and stdcall. The first pass arguments on eax, edx, ecx, ebx before pass control to callee. The last pushes arguments on stack. With this I want to know the best way to pass arguments. The overhead of stdcall can be tolerated, as it's the easiest to use? Or should regcall be used for being lightning fast? I would like to hear your experience.
|
|||||||||||
10 Jan 2005, 15:45 |
|
beppe85 10 Jan 2005, 19:26
I missed the role of the cache, but even so, in leaf routines you need to perform more actions(code).
But no, I'm not considering routines with many parameters, having 6 as ideal maximum, the point I could think in build up structures or break subroutine in smaller functional parts. I want to broaden the scope of the question a little. I usually set (eax,edx, ecx) as caller-save and the others as callee-save. What combination do you think is best, for both speed and ease? |
|||
10 Jan 2005, 19:26 |
|
crc 11 Jan 2005, 01:38
I use a custom stack for passing data. (eax is the top of my stack, esi points to the rest of it. A few macros simplify using it). The hardware stack is mostly used for return addresses (I have a lot of small functions and sometimes being able to manipulate the hardware stack is helpful)
Register-based calling conventions are worse in my view as you have to save/restore the registers. Passing them directly on the hardware stack reduces the impact on the register useage even further. |
|||
11 Jan 2005, 01:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.