flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Do fasmg use special names for local?

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 648
Code:
macro f {
      local x
      cusdis x
}
macro cusdis x {
      display `x
}
f      
displays x?0

Code:
macro test
        local t
        cusdis t
end macro

macro cusdis x
        display `x
end macro

test    
displays t

Cuz if special names may accidently have same name causing bugs
Post 08 Feb 2019, 02:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16509
Location: M87*
The same problem exists in fasm also
Code:
x?0 = '2'
macro f {
        local x
        x = '4'
        cusdis x
}
macro cusdis x {
        display `x,' = ',x,13,10
}
display 'x?0 = ',x?0,13,10
f
display 'x?0 = ',x?0,13,10    
displays
Code:
x?0 = 2
x?0 = 4
x?0 = 4    
Post 08 Feb 2019, 03:38
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
If not can't be used to make local group
Code:
macro test i
        local t
        t equ 49
        t#1 equ 51
        display i
        cusdis i
        display t
        cusdis t
        display i#1
        cusdis i#1
        display t#1
        cusdis t#1
end macro

macro cusdis x
        display 32,`x,10
end macro

t equ 48
t1 equ 50
test t    
Code:
0 t
1 t
3 t#1
3 t#1    
Post 08 Feb 2019, 05:17
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7237
Location: Kraków, Poland
In fasmg local symbols are not replaced with a different names like fasm's preprocessor does it, instead they reside in a different namespace - a special namespace associated with macro. When you use such symbol, for example in parameters to call other macros (or in symbolic variables), the "recognition context" which states in which namespace the name should be understood, is copied along with it (invisible to normal text processing, think of it as a text attribute like color).

Therefore even if you attach a number to such name, it is still going to be interpreted in the local namespace - it is enough that the beginning of a name is "colored" as such.

Thanks to that your above snippet does in fact show the same values as analogous code for fasm 1. Definitions "t equ 48" and "t1 equ 50" do not have any effect, because they are symbols in a completely different namespace.

In fasm you could "hack" the local symbols separation by defining a conflicting name manually, in fasmg it is not possible, because you have no access to macro's local namespace other than through LOCAL directive.

Perhaps you should tell us what problem you are trying to solve.
Post 08 Feb 2019, 06:38
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
Quote:
Therefore even if you attach a number to such name, it is still going to be interpreted in the local namespace - it is enough that the beginning of a name is "colored" as such.
If so why
Code:
display i#1    
displays 3(51) rather than 2(50)?

EDIT: Am I using a too old version(0.97.1470594768)?
Post 08 Feb 2019, 10:27
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7237
Location: Kraków, Poland
It displays 2 for me. Why are you using such an antique version? It's been a long time since I switched to a base 36 versioning scheme. 0.9x should be considered pre-releases.
Post 08 Feb 2019, 11:39
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
I guess I downloaded fasmg years ago and don't update...
Post 08 Feb 2019, 14:26
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-2019, Tomasz Grysztar.

Powered by rwasa.