flat assembler
Message board for the users of flat assembler.

Index > Main > Dynamic macro definition?

Author
Thread Post new topic Reply to topic
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank 28 Feb 2012, 15:03
Is there any way to define macro, in other macro, with name which depends on arguments of parent macro.
For example:

Code:
macro cdecl label {
; here should be defined macro with name "c#label"
;...
}
cdecl printf
;...
cprintf pattern1,eax

    
Post 28 Feb 2012, 15:03
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 28 Feb 2012, 19:35
Yes:
Code:
macro x id
{
        macro x#id [x] \{ dd x \}
}

x dummy
xdummy 5    
Hope that helps Cool
Post 28 Feb 2012, 19:35
View user's profile Send private message Reply with quote
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank 28 Feb 2012, 21:23
Yes! It works!
But something more complex, like that, doesn`t work:

added after few minutes:

And more complex also works! Problem were in backslashes, or rather the lack thereof in right places.


Last edited by Blank on 28 Feb 2012, 21:35; edited 1 time in total
Post 28 Feb 2012, 21:23
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 28 Feb 2012, 21:28
macro id#lst [x] \\{ -> macro id\#lst [x] \\{

PS: I think you want to move forward below "macro names ..."(remember to use \forward if you move it)
Post 28 Feb 2012, 21:28
View user's profile Send private message Reply with quote
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank 28 Feb 2012, 21:39
Yeah! I`m already understand that.
PS: yes

These blackslases make me strain.
Post 28 Feb 2012, 21:39
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 07 Mar 2012, 11:27
Blank,

Backslash escaping is the essence of any proficient fasm macro language usage. I'm still developing fasmw fork that will highlight exact nesting level corresponding to backslash to the left of the cursor.
Post 07 Mar 2012, 11:27
View user's profile Send private message 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.