flat assembler
Message board for the users of flat assembler.
Index
> Main > iCall somthing like inline function in fasm. |
Author |
|
revolution 25 Jul 2019, 15:59
Inline would generally just be a macro.
Code: macro do_something { xor eax,eax } proc do_it do_something ret endp call do_it ;function call do_something ;inline |
|||
25 Jul 2019, 15:59 |
|
Roman 26 Jul 2019, 06:11
I suggest such:
Code: macro do_something { xor eax,eax } proc do_somethingProc do_something ret endp ;I do not know whether this macro will work right macro iCall flg,chMacr { if flg=1 chMacr endif if flg=0 Call chMacr#Proc endif } Use in code: Code: inlineFlagProc1 EQU 1 ;iCall might call many procs ! One iCall do many macros or Call procs. iCall inlineFlagProc1,do_something iCall inlineFlagProc1,do_something,do_something2,do_something3 Last edited by Roman on 26 Jul 2019, 08:13; edited 3 times in total |
|||
26 Jul 2019, 06:11 |
|
DimonSoft 26 Jul 2019, 07:11
So, what’s the purpose? Inlining as one of optimization techniques is not only about putting the procedure body at the call site (although it’s definitely the way to start) but also certain changes at the machine-code level that make such placement efficient: reusing values in registers thus avoiding unnecessary stack/memory accesses, etc. It’s not what can generally be achieved without serious analysis. Just try to write such macro + proc with a few parameters and see how your code gets bloated with useless stuff like moving data between and pushing/popping it (either in caller or callee).
|
|||
26 Jul 2019, 07:11 |
|
Roman 26 Jul 2019, 08:04
Quote: So, what’s the purpose? If i using many procs i need fast way change Call on code to macro ! Very hard find many procs in differents places of code. iCall very helpfull. Only change inlineFlag on null or 1 thats all. I agree, some times proc optimization is needed and gives short and fast code. |
|||
26 Jul 2019, 08:04 |
|
DimonSoft 27 Jul 2019, 08:29
But you gain little to nothing by simply putting procedure body in the caller. The only thing you might gain by blindly copying the body is to remove procedure call overhead but this stuff is quite optimized in hardware these days and, due to speculative execution, the overhead might sometimes even become invisible, so in such cases you would gain larger executable and worse data locality (remember caches and prefetcher). And again, when writing some piece of code in such a way that it is usable as both separate and inlined procedure you might introduce overheads for both cases. Chasing two rabbits usually gets nothing.
|
|||
27 Jul 2019, 08:29 |
|
Roman 27 Jul 2019, 08:32
Quote: Chasing two rabbits usually gets nothing. Hm ! Rabbits very tasty When you know how to cook them ! |
|||
27 Jul 2019, 08:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.