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
Thread Post new topic Reply to topic
flatnoob



Joined: 24 May 2006
Posts: 5
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.
Post 29 May 2006, 08:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
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 Wink
Post 29 May 2006, 08:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
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)
Post 29 May 2006, 09:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 29 May 2006, 11:14
You just have to redefine prologue/epilogue macros (adjustable with "prologue@proc" and "epilogue@proc" symbolic variables).
Also with macro/masm.inc you've got an option:
Code:
option prologue:none
option epilogue:none    


Last edited by Tomasz Grysztar on 29 May 2006, 23:12; edited 1 time in total
Post 29 May 2006, 11:14
View user's profile Send private message Visit poster's website Reply with quote
zubi



Joined: 27 Apr 2006
Posts: 25
Location: Turkey
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.
Post 29 May 2006, 15:00
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
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
Post 29 May 2006, 16:43
View user's profile Send private message Visit poster's website Reply with quote
flatnoob



Joined: 24 May 2006
Posts: 5
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).
Also with macro/masm.inc you've got an option:
Code:
setting prologue:none
setting epilogue:none    

And where should I put these settings when I include masm.inc?
Post 29 May 2006, 20:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
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
Post 29 May 2006, 20:21
View user's profile Send private message Visit poster's website Reply with quote
blacky



Joined: 06 Apr 2006
Posts: 32
Location: JA
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?
Post 29 May 2006, 20:26
View user's profile Send private message MSN Messenger Reply with quote
flatnoob



Joined: 24 May 2006
Posts: 5
flatnoob 29 May 2006, 22:08
Tomasz Grysztar wrote:
After all include statements - if you want to make those settings global.
Otherwise - just before the procedure you want to define with those settings


I get "error: illegal instruction" compile error if I place any of these lines anywhere. Confused
I have these includes:
include 'win32a.inc'
include 'macro\if.inc'
include 'macro\masm.inc'
Post 29 May 2006, 22:08
View user's profile Send private message Reply with quote
zubi



Joined: 27 Apr 2006
Posts: 25
Location: Turkey
zubi 29 May 2006, 22:18
Thank you very much for the "supplemental configuration" macros. They are exactly what I needed.
Post 29 May 2006, 22:18
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 29 May 2006, 23:14
flatnoob wrote:
I get "error: illegal instruction" compile error if I place any of these lines anywhere. Confused

Sorry, my stupid mistake - I wrote "setting" where I should have written "option". I edited my posts to correct this.
Post 29 May 2006, 23:14
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
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
Post 29 May 2006, 23:17
View user's profile Send private message Reply with quote
flatnoob



Joined: 24 May 2006
Posts: 5
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". Confused


Last edited by flatnoob on 29 May 2006, 23:32; edited 1 time in total
Post 29 May 2006, 23:27
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
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.
Post 29 May 2006, 23:31
View user's profile Send private message Visit poster's website Reply with quote
flatnoob



Joined: 24 May 2006
Posts: 5
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.
Post 29 May 2006, 23:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
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.
Post 30 May 2006, 01:36
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
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.
Post 30 May 2006, 15:40
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
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" ?
Post 30 May 2006, 17:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
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.
Post 30 May 2006, 17:50
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.