flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Problem with multiple global data macros

Author
Thread Post new topic Reply to topic
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
I noticed that now idata and udata (or older iglobal, uglobal) don't work when there's more than one occurence of each one:
Code:
udata
  test1                         dd ?
endg

udata
  test2                         dd ?
endg
        mov     eax, test1 ; Error: undefined symbol
        mov     eax, test2    
It doesn't work with initialized data (idata) either. But If I rip off second udata block and 'mov eax, test2' line it will compile. Tested with the newest FASM release and both old and new version of global data macros. What's wrong?
Post 12 Nov 2005, 12:35
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
As there are no such macros in official fasm macro set, please post the macros that you're using, too.
Post 12 Nov 2005, 13:42
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
You didn't forgot about IncludeAllGlobals, did you? Wink
Can you post your macros? With macros form Fresh package you you can declare two or more data blocks one after another, without 'undefined symbol error'.

Code:
macro iglobal { IGlobals equ IGlobals,
                macro __IGlobalBlock { }

macro uglobal { UGlobals equ UGlobals,
                macro __UGlobalBlock { }

endg fix }

macro IncludeIGlobals { macro IGlobals dummy,[n] \{ __IGlobalBlock
                                                    purge __IGlobalBlock \}
                        match I, IGlobals \{ I \} }


macro IncludeUGlobals { macro UGlobals dummy,[n] \{ \common \local begin, size
                                                     begin = $
                                                     virtual at $
                                                    \forward
                                                     __UGlobalBlock
                                                     purge __UGlobalBlock
                                                    \common
                                                     size = $ - begin
                                                     end virtual
                                                     rb size \}
                        match U, UGlobals \{ U \} }

macro IncludeAllGlobals {
  IncludeIGlobals
  align 4
  IncludeUGlobals
}    


BTW I added 'align 4' to IncludeAllGlobals in latest package.
Post 12 Nov 2005, 14:00
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
I don't get it. It works now. I used macros provided by vid for FASMLIB and comparing line by line it was nearly identical. The difference was only macro-arguments name, or sth like this. I have no idea why didn't it work, but thanks anyway for help
Post 12 Nov 2005, 14:54
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
strange Wink
I was thinking about improving this macros, so for instance such construction would be possible:

Code:
uglobal
    sth dd ?
iglobal
   sth2 db 'safsaf'
endg    


so iglobal and uglobal macros will automatically close previous blocks if necessary, thus data declarations will look a little nicer Wink Can someone help?
Post 12 Nov 2005, 16:34
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
I think something like this should do the trick:
Code:
macro _iglobal dummy { IGlobals equ IGlobals,
                       macro __IGlobalBlock { }

macro _uglobal dummy { UGlobals equ UGlobals,
                       macro __UGlobalBlock { }


iglobal fix _iglobal } _iglobal
uglobal fix _uglobal } _uglobal
endg fix }

macro IncludeIGlobals { macro _iglobal dummy \{ \}
                        macro _iglobal dummy \{ \}
                        macro IGlobals dummy,[n] \{ __IGlobalBlock
                                                    purge __IGlobalBlock \}
                        match I, IGlobals \{ I \} }


macro IncludeUGlobals { macro _iglobal dummy \{ \}
                        macro _iglobal dummy \{ \}
                        macro UGlobals dummy,[n] \{ \common \local begin, size
                                                     begin = $
                                                     virtual at $
                                                    \forward
                                                     __UGlobalBlock
                                                     purge __UGlobalBlock
                                                    \common
                                                     size = $ - begin
                                                     end virtual
                                                     rb size \}
                        match U, UGlobals \{ U \} }    
Post 12 Nov 2005, 20:25
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
OK it works, assuming you wanted to write
Code:
macro IncludeIGlobals { macro _uglobal dummy \{ \}
                        macro _uglobal dummy \{ \}
                        macro IGlobals dummy,[n] \{ __IGlobalBlock
                                                    purge __IGlobalBlock \}
                        match I, IGlobals \{ I \} }     


I think that I can understand how it works (more or less Confused) but why did you write "macro _uglobal dummy \{ \}" twice?
Post 12 Nov 2005, 23:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Oh, it had to be:
Code:
macro _iglobal dummy \{ \}
macro _uglobal dummy \{ \}     

in both cases.
Post 12 Nov 2005, 23:37
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
OK, it works. Thanks!
BTW you don't sleep at nights, do you? Wink
Post 13 Nov 2005, 00:05
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Allright, nice addition to these macros. I find it useful and in fact I'd like to use it in my programs, but there's a problem with unifying standards in FASMLIB. What do you coders of FASMLIB think of that? And also we should change the name to idata/udata as such solution won the poll
Post 13 Nov 2005, 11:59
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
In next Fresh release I'm going to change iglobal/uglobal to idata/udata, I think they are better names, so that's no issue.
Post 13 Nov 2005, 16:11
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
sorry, i wasn't here some time. something wrong with m rewrite of macros? i thin comments there come useful for newbies studying them... but i wass rewrtiing them in hurry, so i may have left something there of course...
Post 14 Nov 2005, 15: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.

Powered by rwasa.