flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] local label

Author
Thread Post new topic Reply to topic
MaoKo



Joined: 07 May 2019
Posts: 100
Location: Paris/French
MaoKo 14 Oct 2019, 18:36
Hello! I'm wonder something (which is obvious, maybe) about local symbol and context. The problem is that, I need to make some reference to some local symbol, and after that purge/override the macro that defined it. Does is safe to do? After some test the value don't go away but I didn't go deeper. In FASM1 it's safe cuz there is a kind of global counter which is increment when a new local is defined. Also in the man I don't really understand a quote:
Quote:

However, such modified context is not relevant if the value of parameter is inserted in a middle or at the end of a complex identifier, because it is the structure of an identifier that dictates how its later parts are interpreted and only the context for an initial part matters.

It's related to what FASM1 does by prepend ?n to local symbol?
Thanks!
Post 14 Oct 2019, 18:36
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 14 Oct 2019, 19:00
MaoKo wrote:
Hello! I'm wonder something (which is obvious, maybe) about local symbol and context. The problem is that, I need to make some reference to some local symbol, and after that purge/override the macro that defined it. Does is safe to do? After some test the value don't go away but I didn't go deeper. In FASM1 it's safe cuz there is a kind of global counter which is increment when a new local is defined.
Yes, it is safe. The namespace where these symbols reside is related to the instance of a macro - a specific evaluation of macro where it is called, and this is in no way connected to the definition of the macro (the definition only decides what text of macro is executed when you call it again).

MaoKo wrote:
Also in the man I don't really understand a quote:
Quote:

However, such modified context is not relevant if the value of parameter is inserted in a middle or at the end of a complex identifier, because it is the structure of an identifier that dictates how its later parts are interpreted and only the context for an initial part matters.

It's related to what FASM1 does by prepend ?n to local symbol?
Thanks!
No, what this means is that if you define a name as local, it only matters when you use it as an initial of an identifier:
Code:
macro test
    local name
    name = 1 ; this is local
    name.x = 1 ; this is also local
    x.name = 1 ; this is global (in the namespace of global "x")
end macro    
This happens to give results similar to fasm 1, but for different reason. In fasm 1 "." was not a special character, so "x.name" was just a single token and "name" was not seen there. In fasmg "name" is processed there, but the change of context does not matter, because it is not an initial symbol of the identifier.
Post 14 Oct 2019, 19:00
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.