flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg, calm] what happens if local symbol is defined twice?

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak
Maybe a dumb question, but I do not completely understand what happens inside when I define the same local symbol many times.

Code:
calminstruction inst
  local sym, sym
end calminstruction
    


Do I end up having two memory regions allocated for the symbol?
Post 28 Apr 2021, 14:31
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak
Looks like no, as
Code:
calminstruction inst
    local sym
    
    arrange sym, '1'
    asmcmd =display sym

    local sym
    asmcmd =display sym
end calminstruction
    

just displays two '1's
Post 28 Apr 2021, 14:39
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7925
Location: Kraków, Poland
Tomasz Grysztar
Each CALM instruction has its own namespace, and LOCAL just forces a symbol to be considered present in that namespace, to prevent looking for global definitions. Note that if there is no global (meaning: in any of the parent namespaces) symbol defined with such name, then the one in the instruction's own namespace is going to be used anyway (even if you do not use LOCAL). What CALM's LOCAL actually does is that it gives the symbol a defined but unusable value, to force the symbol look-up to stop at the local level instead of going to the parent namespaces.
Post 28 Apr 2021, 14:59
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.