flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > processing macro names

Author
Thread Post new topic Reply to topic
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 13 Nov 2006, 09:27
Hi!

Anybody can explain this:
Code:
macro m name*,[args]
 {
common
        local nname
        nname equ ?#name#@@YGI ; ok, preprocessed: nname?0000000 equ ?fot@@YGI
        match a,args
        \{
                forward
                        nname equ nname\#I
                common
                        nname equ nname\#@Z
        \}
        match ,args
        \{
                nname equ nname\#Z ; wrong! preprocessed: nname?0000000 equ nname?0000000Z
        \}
                nname: ; nname?0000000Z: 
                 dd 0
 }


macro m2 name*,[args]
 {
common
        local nname
        nname equ ?#name#@@YGI ; ok: nname?0000001 equ ?foo@@YGI
        match a,args
        \{
                forward
                        match n,nname \\{ nname equ n\\#I \\}
                common
                        match n,nname \\{ nname equ n\\#@Z \\}
        \}
        match ,args
        \{
                match n,nname \\{ nname equ n\\#Z \\} ; ok: nname?0000001 equ ?foo@@YGIZ
        \}
                nname: ; ok: ?foo@@YGIZ:
                 dd 0
 }

m fot
m2 foo

    


What I must to do to receive actual new name without inserting this matches? Why without it I got glued local names, but not actual name?
Please, explain me this.
Post 13 Nov 2006, 09:27
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Nov 2006, 10:50
same problem i had recently. no idea why it's needed too Sad
Post 13 Nov 2006, 10:50
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Nov 2006, 11:08
i'm using "..label" for locals in macro
=====
↓now got it Smile i mixed it with other situation


Last edited by shoorick on 13 Nov 2006, 13:20; edited 2 times in total
Post 13 Nov 2006, 11:08
View user's profile Send private message Visit poster's website Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 13 Nov 2006, 11:40
..label not necessary here, this macroses for example. And it isn't helps :)
Post 13 Nov 2006, 11:40
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Nov 2006, 12:49
Can you explain in detail which part you expect to work differently?
Post 13 Nov 2006, 12:49
View user's profile Send private message Visit poster's website Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 13 Nov 2006, 13:11
I want to ask, is match so necessary to get actual name in symbolic constant? Or an other ways are exist?
Post 13 Nov 2006, 13:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Nov 2006, 13:18
What do you mean by 'actual name'? (Sorry, perhaps I slept too short today...)
Post 13 Nov 2006, 13:18
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Nov 2006, 13:20
Oh, OK, I get it - the second macro is the one that works correctly for you, isn't it?
Yes, you have to do it with "match" - because concatenation can be done only by macro, the EQU directive itself cannot do a conctatenation for you.
Post 13 Nov 2006, 13:20
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 13 Nov 2006, 13:47
your explaination doesn't clear for me, why this doesn't work (as expected):
Code:
macro a {
X equ something
X equ X#abcd  ;this doesn't append abcd to X
}    
Post 13 Nov 2006, 13:47
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: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Nov 2006, 14:21
Concatenation operator is a line-maker operator, it is done while new line is generated by the macroinstruction. The EQU is standard preprocessor's directive, which are interpreted after the line is already generated. The line is thus generated by macro processor as "X equ Xabcd" and then preprocessed.

The MATCH is generally useful when you need to pass the contents of symbolic variable to the line-maker.
Post 13 Nov 2006, 14:21
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 13 Nov 2006, 15:33
thx
Post 13 Nov 2006, 15:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 13 Nov 2006, 16:29
Thank you.
Post 13 Nov 2006, 16:29
View user's profile Send private message Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 25 Jan 2007, 14:21
Hi.

I have another problem with macro parameters.

I want to pass parameter to macro and want to save it into temporary name to use later in another macro.

macro MyMacro param1, param2
{
temp_param = param1
}

but it generate error. Is there some way to define temporary global names whithin macro?
Post 25 Jan 2007, 14:21
View user's profile Send private message ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 25 Jan 2007, 15:29
afw2004: "=" is assembly-time thing for numeric constant. use "equ"
Post 25 Jan 2007, 15:29
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.