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

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.
29 May 2006, 08:33
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
29 May 2006, 08:49
shoorick

Joined: 25 Feb 2005
Posts: 1613
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)
29 May 2006, 09:05
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8095
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
29 May 2006, 11:14
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.
29 May 2006, 15:00
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8095
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
29 May 2006, 16:43
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?
29 May 2006, 20:10
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8095
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
29 May 2006, 20:21
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?
29 May 2006, 20:26
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.
I have these includes:
include 'win32a.inc'
include 'macro\if.inc'
include 'macro\masm.inc'
29 May 2006, 22:08
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.
29 May 2006, 22:18
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8095
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.

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

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

start: ret    ```

I'm using FASM 1.66
29 May 2006, 23:17
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".

Last edited by flatnoob on 29 May 2006, 23:32; edited 1 time in total
29 May 2006, 23:27
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8095
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.
29 May 2006, 23:31
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.
29 May 2006, 23:36
LocoDelAssembly

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.
30 May 2006, 01:36
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.
30 May 2006, 15:40
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" ?
30 May 2006, 17:00
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.
30 May 2006, 17:50
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area
Goto page 1, 2  Next

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum