flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > nested macro problem

Author
Thread Post new topic Reply to topic
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One 04 Jun 2005, 04:18
While trying to implement a STRUCT macro set (for structure declaration), i need to write some code like below (just an example) :
Code:
macro A {
 if ~x eq
   dd x
 end if
}

macro B {
 struc C x, y \{
  A
 \}
}
    

(the x inside A is for representing the x that act as argument to C, and A is a dynamically defined macro). I need A to be expanded when B is called, i.e :
Code:
B

;becomes
;struc C x, y {
; if ~x eq
;  dd x
; end if
;}

;and not
;struc C x, y {
; A
;}

    


how do I achieve this?

my english isnt good. i hope i explained it corectly.
Post 04 Jun 2005, 04:18
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 04 Jun 2005, 07:57
During macro definition there are no directives interpreted and no macros expanded, so it means it's impossible to expand definition of one macro inside definition of another.

You can just do some passing of parameters from one macro to another to achieve required result:
Code:
macro A x {
 if ~x eq
   dd x
 end if
}

macro B {
 struc C x, y \{
  A x
 \}
}
    
Post 04 Jun 2005, 07:57
View user's profile Send private message Visit poster's website Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One 11 Jun 2005, 07:28
thanks privalov.. thats work.. now i need to review my macros on how to adapt this.
Post 11 Jun 2005, 07:28
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.