flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > equ trick

Author
Thread Post new topic Reply to topic
pps05



Joined: 18 Dec 2007
Posts: 6
Location: Minsk, Belarus
pps05 18 Dec 2007, 18:58
I want to define such macro (mymacro) that

Code:
mymacro name
mymacro anothername
mymacro yetanothername
    


is assembled to

Code:
name equ anothermacro 1
anothername equ anothermacro 2
yetanothername equ anothermacro 3
    


and so on 'mymacro nextname' is assembled to 'nextname equ anothermacro 4'...

How can I do it?
Post 18 Dec 2007, 18:58
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 18 Dec 2007, 21:27
Code:
define counter@mymacro 0

macro mymacro name
{
 match c,counter@mymacro \{ rept 2 x:c \\{ define counter@mymacro x \\} \}
 match c,counter@mymacro \{ name equ anothermacro c \}
}    

First line of the macro increases the counter@mymacro by 1, the second one does the assignment you requested.
Post 18 Dec 2007, 21:27
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 18 Dec 2007, 21:31
You can also make it as one-liner Wink

Code:
macro mymacro name { match c,counter@mymacro \{ rept 2 x:c \\{ define counter@mymacro x \\} \} match c,counter@mymacro \{ name equ anothermacro c \} } define counter@mymacro 0    
Post 18 Dec 2007, 21:31
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 19 Dec 2007, 09:04
If really feels like what we're looking for here is ENUM, maybe try that one out.
Post 19 Dec 2007, 09:04
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
pps05



Joined: 18 Dec 2007
Posts: 6
Location: Minsk, Belarus
pps05 19 Dec 2007, 16:05
Thank you, it's the thing that I need. Is it impossible to do that without 'match' and 'rept'? Madis731, I need to place 'mymacro' anywhere in source, so ENUM doesn't look like a good idea.
Post 19 Dec 2007, 16:05
View user's profile Send private message ICQ Number 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.