flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Nested Functions

Author
Thread Post new topic Reply to topic
jvff



Joined: 05 Jul 2005
Posts: 5
Location: Brazil
jvff 05 Jul 2005, 15:01
Hello,

I would like to know if there is something like nested functions in fasm preprocessor. This way one could do something like

Code:
start:
 func1:
  func2:
 func3:    


So the nest is defined by spaces or tab spaces (further apart from start of line = deeper in nest).

Using it like this
Code:
start.func1.func2    


Is there such feature or similiar? Thank you,

JVFF
Post 05 Jul 2005, 15:01
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 05 Jul 2005, 15:35
I tried to design some clever macros doing such things:
Code:
macro undefine [name]
 { local undefined
   name equ undefined }

macro func name
 { match any, subs@func
   \{ tmp@func equ subs@func
      restore subs@func
      subs@func equ tmp@func,name \}
   match , subs@func
   \{ restore subs@func
      subs@func equ name \}
   match parent, fullname@func
   \{ fullname@func equ parent\#.\#name
      fullname@func: \}
   match , fullname@func
   \{ fullname@func equ name \}
   subs@func equ
   name: }

macro endf
 { match subs, subs@func \{ undefine subs \}
   restore subs@func
   restore fullname@func }

fullname@func equ    

Use them like:
Code:
func start
 func func1
  func func2
  endf
 endf
 func func3
 endf
endf


func start2
 call func1             ; calls start2.func1
 call start.func1
 call start.func1.func2

 func func1
 endf
endf    
Post 05 Jul 2005, 15:35
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 05 Jul 2005, 15:39
well - there are no "functions" in FASM's preprocessor. Did you mean macros, procedures or just nested labels (namespaces) - there was thread about these, try searching.
Post 05 Jul 2005, 15:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
jvff



Joined: 05 Jul 2005
Posts: 5
Location: Brazil
jvff 05 Jul 2005, 15:47
Thank you very much Smile I'm slowly migrating from NASM to FASM and I'm quite perplexed by it's macro abilities. That's exactly what I needed. I will try to learn more about macros so I can do some changes to it so I can use it with proc, invoke, and as labels. Again Thank you,


JVFF
Post 05 Jul 2005, 15:47
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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.