flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > match question...

Author
Thread Post new topic Reply to topic
Joshua



Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 02 Jul 2006, 11:08
EDIT: The example in this post is not correct as Privalov explains in the next post!

As you probably would have guessed, i'm in the process of updating all my macro's from some older fasm versions. And of course I found another oddity...

When doing this:
Code:
macro m var {
 const.#var#.1 equ 1
 match =z,z \{ const.#var#.2 equ 2 \}
}
a equ b
m a    

you get: const.a.1 equ 1, const.b.2 equ 2

this because it is evaluated like this:
Code:
const.a.1 equ 1
;const.#a#.2 equ 2
const.b.2 equ 2    

In other words, equates are replaced in the match segment when first encountered, and then replaced again, when the segment is actually executed.

Once again, is this intended behavior, and is there a way around it? (i tried escaping (\), but that doesn't work, as the escape isn't executed the first run of course...)


Last edited by Joshua on 02 Jul 2006, 12:17; edited 2 times in total
Post 02 Jul 2006, 11:08
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 02 Jul 2006, 11:51
Actually you get "const.a.1 equ 1" and "const.a.2 equ 2" here.

PS. Look into section 2.3.7 to get the information necessary for interpretations.
Post 02 Jul 2006, 11:51
View user's profile Send private message Visit poster's website Reply with quote
Joshua



Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 02 Jul 2006, 12:15
Sorry, you're right, i interpreted the results wrong...
What i need is a list of macro variables actually...
Code:
macro m var { List equ List,var }
a equ 1
m a    

In old versions with fix this resulted in: List fix List,a
Now with all equates this is: List equ List,1 (because equ evaluates equ)
Post 02 Jul 2006, 12:15
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 02 Jul 2006, 12:26
i think there is "define" which doesn't evaluate equates on it's right side, see manual, i'm not sure
Post 02 Jul 2006, 12:26
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 02 Jul 2006, 12:37
That's right, you should use DEFINE:
Code:
macro m var
{
  match list_elements, List \{ define List list_elements,var \}
}

a equ 1
m a
    

(the MATCH is needed because "define List List,var" wouldn't replace the "List" and thus would be unuseful).
Post 02 Jul 2006, 12:37
View user's profile Send private message Visit poster's website Reply with quote
Joshua



Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 02 Jul 2006, 14:30
thanks!
Post 02 Jul 2006, 14:30
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.