flat assembler
Message board for the users of flat assembler.
Index
> Main > 'call' and 'push' |
Author |
|
okasvi 23 Apr 2006, 00:07
not if function handles it's stack properly
|
|||
23 Apr 2006, 00:07 |
|
vid 23 Apr 2006, 02:22
i am not sure if i understand you correctly, but if you are asking whether "function" removes [argument] from stack, then answer is that it depends on function (of course). There are several so-called calling conventions, most common are "pascal" (arguments pushed left to right, called procedure removes argument from stack), "stdcall" (arguments pushed right to left thus allowing variable number of arguments like with printf(), called procedure removes argument form stack) and "cdecl" (right to left, called procedure does NOT remove arguments, you must "add esp, size_of_arguments" after call.
|
|||
23 Apr 2006, 02:22 |
|
RedGhost 23 Apr 2006, 03:27
vid wrote: i am not sure if i understand you correctly, but if you are asking whether "function" removes [argument] from stack, then answer is that it depends on function (of course). There are several so-called calling conventions, most common are "pascal" (arguments pushed left to right, called procedure removes argument from stack), "stdcall" (arguments pushed right to left thus allowing variable number of arguments like with printf(), called procedure removes argument form stack) and "cdecl" (right to left, called procedure does NOT remove arguments, you must "add esp, size_of_arguments" after call. it is cdecl that allows many parameters "..." in C, because the stack is balanced after the procedure so the compiler or writer can calculate the needed bytes for the stack balance based on the number of parameters passed, printf is cdecl _________________ redghost.ca |
|||
23 Apr 2006, 03:27 |
|
vid 23 Apr 2006, 10:21
RedGhost: yes, my mistake. But if you look deeper into it, you can't handle "..." in some "normal" way with C, you would have to do some pointer magic. So most of procs which take "..." are asm procs anyway. And in asm, you can clear the stack as needed inside procedure.
but it's theory, what you said is reality |
|||
23 Apr 2006, 10:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.