flat assembler
Message board for the users of flat assembler.

Index > Windows > Symbol already defined. How come?

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 27 Jun 2003, 03:17
Code:
;##########################################################################
proc cacheMX,.pszAddress,.addr
        enter
        xor     eax,eax
        return
;##########################################################################
proc getMX,.pszDomain,.lpServers,.dwDepth
        .addr   rd 02h    



On compilation it points to the last line (.addr rd 02h) saying "symbol already defined"- ..arg?00031C6E rd 02h.

If I change cacheMX's last parameter .addr to a different name it compiles fine.

I was under impression that symbol starting with . are local and should not interfere with each other. What is wrong?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Jun 2003, 03:17
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Jun 2003, 06:05
Hi.
Look at "proc" macro definition. It's simply not correct to use "pointed" labels as procedure parameters, but only as local variables

Code:
;##########################################################################
proc cacheMX,pszAddress,addr
        enter
        xor     eax,eax
        return
;##########################################################################
proc getMX,pszDomain,lpServers,dwDepth
        .addr   rd 02h
        enter
.......
        return
    
Post 27 Jun 2003, 06:05
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 27 Jun 2003, 09:21
Yeah, playing with macro may cause things that look illogical but it will become clear why did it happen when look closer at what preprocessor feeds into parser. In the proc macro you have the following lines:
Code:
     local ..arg
     ..arg dd ?
     arg equ ..arg    

So for each argument macro generates some name like ..arg?000008BD, which will be available globally, but won't break the locals. Then it declares the virtual variable of that name, and then declares the symbolic constant of the name given by you to be equal to that generated name (for example addr equ ..arg?000008BD). I've made it this way to allow you to use names for arguments not beginning with dot, while still being allowed to define local variables and labels for the proc.
Symbolic constant is declared for the rest of the source (unless it is redefined or cleared with restore directive), so in the next proc your .addr symbol is just replaced with the global name (beginning with two dots) that was already used as a label - that is where the error comes from.
Post 27 Jun 2003, 09:21
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 27 Jun 2003, 21:38
Shocked Shocked Shocked Shocked Shocked

So what should I do? Laughing

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Jun 2003, 21:38
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 27 Jun 2003, 21:53
It depends on what do you want to do.
Post 27 Jun 2003, 21:53
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 27 Jun 2003, 23:28
Should I follow JohnFound's code?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Jun 2003, 23:28
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Jun 2003, 08:49
Well, it was intended to be used just in that way.
Post 28 Jun 2003, 08:49
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.