flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > "noframe" option in proc to disable stack frame? Goto page 1, 2 Next |
Author |
|
flatnoob 29 May 2006, 08:33
How can I do this?
And it would be nice if it was automatically ignored when there are locals used. Thx. |
|||
29 May 2006, 08:33 |
|
vid 29 May 2006, 08:49
then there would also be no arguments, not only no locals.
you need to modify proc macro in include/macro/proc32.inc, may be somewhat complicated |
|||
29 May 2006, 08:49 |
|
shoorick 29 May 2006, 09:05
if you do not use params/local vars then proc macro does not create stack frame (check in debugger/disasm)
|
|||
29 May 2006, 09:05 |
|
zubi 29 May 2006, 15:00
I actually have the opposite problem. What I need is to have a stack frame even if the proc has no locals or parametes. I don't know how to manipulate proc macros to achieve this, so any help will be appreciated.
|
|||
29 May 2006, 15:00 |
|
Tomasz Grysztar 29 May 2006, 16:43
zubi, this should work for your problem:
Code: macro prologue_forcedframe procname,flag,parmbytes,localbytes,reglist { push ebp mov ebp,esp if localbytes sub esp,localbytes end if irps reg, reglist \{ push reg \} } macro epilogue_forcedframe procname,flag,parmbytes,localbytes,reglist { irps reg, reglist \{ reverse pop reg \} leave if flag and 10000b retn else retn parmbytes end if } prologue@proc equ prologue_forcedframe ; or with MASM.INC "option prologue:prologue_forcedframe" epilogue@proc equ epilogue_forcedframe PS. You don't need to modify the standard includes, the above definition are just a "supplemental configuration" - remember to put them AFTER including the standard macros. Last edited by Tomasz Grysztar on 29 May 2006, 23:12; edited 1 time in total |
|||
29 May 2006, 16:43 |
|
flatnoob 29 May 2006, 20:10
Tomasz Grysztar wrote: You just have to redefine prologue/epilogue macros (adjustable with "prologue@proc" and "epilogue@proc" symbolic variables). And where should I put these settings when I include masm.inc? |
|||
29 May 2006, 20:10 |
|
Tomasz Grysztar 29 May 2006, 20:21
After all include statements - if you want to make those settings global.
Otherwise - just before the procedure you want to define with those settings, and after it restore the settings to default with: Code: option prologue:prologuedef option epilogue:epiloguedef Last edited by Tomasz Grysztar on 29 May 2006, 23:13; edited 1 time in total |
|||
29 May 2006, 20:21 |
|
blacky 29 May 2006, 20:26
If youre not going to use any locals or args, why not use labels and the call instruction?
Code:
..code.ccode
....
call procedure
...
...
....
...
procedure:
..code.
..code
And u can use ret to return Does call automatically create a stack frame? This way of course shouldnt mess at all with the stack... you can actually use call or jmp.. and avoid using 'proc' alltogether.. correct me if im wrong? |
|||
29 May 2006, 20:26 |
|
flatnoob 29 May 2006, 22:08
Tomasz Grysztar wrote: After all include statements - if you want to make those settings global. I get "error: illegal instruction" compile error if I place any of these lines anywhere. I have these includes: include 'win32a.inc' include 'macro\if.inc' include 'macro\masm.inc' |
|||
29 May 2006, 22:08 |
|
zubi 29 May 2006, 22:18
Thank you very much for the "supplemental configuration" macros. They are exactly what I needed.
|
|||
29 May 2006, 22:18 |
|
Tomasz Grysztar 29 May 2006, 23:14
flatnoob wrote: I get "error: illegal instruction" compile error if I place any of these lines anywhere. Sorry, my stupid mistake - I wrote "setting" where I should have written "option". I edited my posts to correct this. |
|||
29 May 2006, 23:14 |
|
LocoDelAssembly 29 May 2006, 23:17
This compiles for me:
Code: format PE GUI 4.0 entry start include 'win32a.inc' include 'macro\if.inc' include 'macro\masm.inc' option prologue:prologuedef option epilogue:epiloguedef section '.code' code readable executable start: ret I'm using FASM 1.66 |
|||
29 May 2006, 23:17 |
|
flatnoob 29 May 2006, 23:27
Yea now it doesn't complain.
But still it compiles to use EBP to take the params ("mov edi,[par1]" --> "mov edi,[ebp+8]" instead of "mov edi,[esp+8]") which of course generates error without the prologue "mov ebp,esp". Last edited by flatnoob on 29 May 2006, 23:32; edited 1 time in total |
|||
29 May 2006, 23:27 |
|
Tomasz Grysztar 29 May 2006, 23:31
When you do your own frame set up, setting up the way of accessing of parameters is also left to you.
|
|||
29 May 2006, 23:31 |
|
flatnoob 29 May 2006, 23:36
Ahh... that's a bummer. Damn, all this is almost too much trouble just to shave off a couple of unnecessary instructions.
In any case, thanks for the help. You're the best. |
|||
29 May 2006, 23:36 |
|
LocoDelAssembly 30 May 2006, 01:36
ups, sorry, I didn't see the post of Tomasz. When I posted I only saw the zubi's post as the last one.
|
|||
30 May 2006, 01:36 |
|
Reverend 30 May 2006, 15:40
flatnoob: It is possible in FASM to automatically calculate the stack frame and then have ebp free (compiler will trace the stack usage and use only esp for locals and args). There were two or three macro-packs on this board having this. Just search for it.
|
|||
30 May 2006, 15:40 |
|
vid 30 May 2006, 17:00
Reverend: that will be really a big problem. you must take in account all instructions that can alter ESP. And since ESP is general-purpose register, these are almost all instructions. And what will you do, when you find "mov esp, 3" or "mov esp, eax" ?
|
|||
30 May 2006, 17:00 |
|
Reverend 30 May 2006, 17:50
'mov esp, eax' is rathre uncommon - so when deciding to use such solution you must be aware not to use some instructions shich alter esp "unnormally".
Generally, macro allowing esp-based frames should overload: push, pushf, pushad, pop, popf, popad, add, sub'. These instructions are most likely to be used in code. |
|||
30 May 2006, 17:50 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.