flat assembler
Message board for the users of flat assembler.

Index > Main > what can be local?

Author
Thread Post new topic Reply to topic
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 04 Nov 2006, 23:51
i discovered to myself that local can be:
1. labels
in macroses
Code:
  local some_label, ..some_label2
  some_label:
  ..some_label2:
    

in procs
Code:
  .some_label:
    

2. local data - in procedures
Code:
 local my_data[260]:BYTE
    

3. local numeric constants(!?) - in macroses
Code:
 local my_num
  my_num = 5
    


the question is that i haven't found any documentation of 3. - local num constants. But tests show that local directive have influence on num consts in macroses. Is that all right?

_________________
Any offers?
Post 04 Nov 2006, 23:51
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8266
Location: Kraków, Poland
Tomasz Grysztar 05 Nov 2006, 01:32
From the preprocessor's point of view there is no difference between your 3 and 1a. While 1b - "locals in procs", as you called it, is a completely different mechanism, happening at the assembly time, not preprocessing.
Post 05 Nov 2006, 01:32
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 05 Nov 2006, 06:18
thanks, just start understanding more attractive dark corners and snippets because of lack of knowledge in fasm macroses
Post 05 Nov 2006, 06:18
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Nov 2006, 16:46
there are 2 things that can be local.

symbols local to macro, using "local" directive:
Code:
local a, ..c    
. Their name is extended by "?" and random number. Thus, if another macro uses same local name, it will be extended by another number, and so it will have different name. more here: http://decard.net/article.php?body=tajga&chapter=preproc#local

symbol local to another symbol. This is when symbol starts with ".", then it's name is prefixed by name of last (non-local) label. eg. these two codes are same:
Code:
a:
.b:
.c:    

Code:
a:
a.b:
a.c:    


"local"| used to declare procedure's local variables is just macro, unfortunately names same as directive
Post 05 Nov 2006, 16:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 07 Nov 2006, 20:42
So i conclude that making a numeric/symbolic constants in macroses to be LOCAL
Code:
macro some_macro
{
  local my_const
  my_const = BYTE -1
}    

is a good practice to prevent the global numeric/symbolic consts from propagation... Right?
;; as a good practice of using "OR" instead of "+" in complicated types definition, e.g.
Code:
wnd_style = WS_VISIBLE OR WS_POPUP    

_________________
Any offers?
Post 07 Nov 2006, 20:42
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 08 Nov 2006, 00:13
in fact, you should also prefix local name with ".."

see the link i provided in my previous post
Post 08 Nov 2006, 00:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 08 Nov 2006, 19:52
Quote:

in fact, you should also prefix local name with ".."

for local labels yes, but local constants don't need to be prefixed
Post 08 Nov 2006, 19:52
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.