flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > new version of constStr Fresh macro?

Author
Thread Post new topic Reply to topic
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
I have almost completed converting Fresh source to new FASM macro library. But I still can't find out what's wrong with constStr macro. Its current version looks like this:

Code:
macro constStr  lbl, text {
  __StringsArray equ __StringsArray, lbl, text     ;  add to the list
}


macro __IncludeStringConstants dummy, [lbls, text] {
  forward
    if _text eqtype 'A'
      lbls db _text
      sizeof.#lbls = $ - lbls
      db 0
    else
      if text eqtype 0
        lbls = _text
      end if
    end if
}

macro IncludeStringConstants {
  __IncludeStringConstants __StringsArray
}    


It should be used in following way:

Code:
constStr Str1, 'This is string constant'    


and IncludeStringConstants would define all strings. Unfortunatelly it doesn't define anything Wink Any solutions?
Post 09 Oct 2005, 19:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Perhaps you forgot to use "match" to pass the value of "__StringsArray" to the macroinstruction. Try this:
Code:
macro IncludeStringConstants {
 match strings, __StringsArray \{ __IncludeStringConstants strings \}
}    

You can also get rid of "dummy" with "match":
Code:
macro __IncludeStringConstants [lbls, text] {
 ; ...
}

macro IncludeStringConstants {
 match dummy=,strings, __StringsArray \{ __IncludeStringConstants strings \}
}    
and this will also handle the case, when no string was defined at all - the match won't occur in such case, and the macro won't get invoked.
PS. Well, I had also to replace the "_text" with "text" to get it working.
Post 09 Oct 2005, 23:55
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Thanks.
Seems that I still don't really get why match should be used in such cases Embarassed I have to read your descriptions again.
Post 10 Oct 2005, 15:47
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
decard: reread the preprocessing priorities. replacing equates is the least priorized thing (unlike replacing macro/match/whatever arguments), so unrolling body of macro "__IncludeStringConstants" will occur instead. Then in macro contents only "dummy" will have some value, which will be (literaly) "__StringsArray".
hope i got right Smile
Post 10 Oct 2005, 16:59
View user's profile Send private message Visit poster's website AIM Address MSN Messenger 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.