flat assembler
Message board for the users of flat assembler.

Index > Main > What is the "last global label"?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Hey

Code:
   Main:
if 1=2
   Second:
end if
      .subname:
    

How to prevent Second.subname instead of Main.subname label?
Post 05 Aug 2022, 00:11
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3464
Location: vpcmipstrm
bitRAKE
Do you mean:
Code:
   Main:
if 1=2
   ..Second:
end if
      .subname:    

_________________
¯\(°_o)/¯ unlicense.org
Post 05 Aug 2022, 01:11
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 688
Location: Russian Federation, Sochi
ProMiNick
Yes here is breached "The label whose name begins with dot is treated as local label, and its name is
attached to the name of last global label (with name beginning with anything but dot)
to make the full name of this label."
last global label is Main, not Second, symbol Second never defined. but .subname attached to never defined symbol. As I understand last global label is last defined global label (it is intuitive assumption other should be documented because it absolutely contrintuitive).
Here only 2 ways:
fix documentation according to behavior;
or fix behavior according to documentation.


Description: by the way fasm1 & fasmg in this case acts differently
Filesize: 35.97 KB
Viewed: 684 Time(s)

v1xg.jpg



_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 05 Aug 2022, 08:18
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
I guess it hinges on the definition of "last global label". The documentation makes no mention of a "defined" label.
Code:
org '0'
if 0
 x:
 .y:
end if
.z:

;display x      ; error: undefined symbol 'x'.
;display x.y    ; error: undefined symbol 'x.y'.
display x.z     ; 1 passes, 0 bytes.    
Post 05 Aug 2022, 08:32
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Moderators renamed this thread but it is not about labels only.
Another examples:
Code:
   Main:
if 0
   somedata db ?
end if
   .sublabel:   ;  --> somedata.sublabel:
    
Post 05 Aug 2022, 09:35
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
somedata is also a label.
Post 05 Aug 2022, 09:40
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Quote:

somedata is also a label.

Ofcourse but you know what I mean
Post 05 Aug 2022, 09:47
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Can I choose global label somehow back?
Code:
   Main:
define savelabel .
if 0
   somedata db ?
end if
  ; ... revert global
   .sublabel:
    
Post 05 Aug 2022, 10:08
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
I think bitRAKE gave the answer above; to use double dots to avoid making a new "last global label" anchor.
Post 05 Aug 2022, 10:10
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Quote:

I think bitRAKE gave the answer above; to use double dots to avoid making a new "last global label" anchor.

I cannot do that
Post 05 Aug 2022, 10:22
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 688
Location: Russian Federation, Sochi
ProMiNick
revolution wrote:
I think bitRAKE gave the answer above; to use double dots to avoid making a new "last global label" anchor.

I gues author wants understand what "last global label" is.
How double dots help to define "last global label" in true condition and not define in false condition?
He wants apply assembly time condition to definition of "last global label" like it works in fasmg. or will see in documentatiion that it is impossible.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 05 Aug 2022, 11:11
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
The if is a red-herring. The "last global label" is set regardless of the condition.

The same for the double dot, it never sets the "last global label", regardless of any surrounding condition.
Post 05 Aug 2022, 11:26
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Quote:

I gues author wants understand what "last global label" is.

No, it's not my words, it's moderated.
I need some triks for my multisection macro.
Where subsections mixed they can mix last global labels aswell that I don't want.
1) I need to save the last global label
2) Load it back after subsection pass
Code:
   main:
... <-- savelabel somehow, I think to do that via struc
if subsection
  somedata db 0
end if
if 0
  savedlabel:     ;Load back
end if
  .sublabel:
    
Post 05 Aug 2022, 11:39
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Code:
struc getlastglobal
{ match global.rest, . \{ savedlabel equ global \} }


...
.tempvar getlastglobal
...
    
Post 05 Aug 2022, 11:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
Label construction is done by the parser.

Struc is in the preprocessor.

The preprocessor runs first. The parser runs next.

So the preprocessor (struc) has no knowledge of label names. You can't break down label names with struc (or any other preprocessor directive (match, irp, etc.)) because the label names don't yet exist.

Also note that the assembler processes if, which is after the label is constructed. So when you think of what you are trying to do just ignore the lines with if, they make no difference at all, and just make it more confusing.

Basically there is no way to "save" the label name either before or after the parser runs.
Post 05 Aug 2022, 12:24
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
revolution
How did my .namespace macro work then? I took the names, added marker and used that marked names. First of all I can take the names form redefined macros/struc like label,db,dd,etc
Post 05 Aug 2022, 12:36
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18837
Location: In your JS exploiting you and your system
revolution
Because names are not labels. You can add names together to construct other names. But only the parser can convert names into labels.
Post 05 Aug 2022, 12:41
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
So if labels exist the only I do is manipulating with names. Isn't it not enough for my task?
Post 05 Aug 2022, 12:55
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3464
Location: vpcmipstrm
bitRAKE
Symbols are defined where they are - even in [fasmg]. Other techniques are needed to create a symbol in another context or address space. For example, create a local/double-dot symbol and then route a symbol in the desired context.
Code:
Main:
  .Second:
  .subname:


virtual at Main.Second
        Second:
end virtual    
See /fasm/include/macro/proc*.inc for more complex examples - in how local variables are defined in the context of PROC.
Post 05 Aug 2022, 14:32
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 575
Location: Ukraine
Overclick
Such a beautiful solution I've got Cool
All tested and works perfect.
If local labels used user should use one-line subsection instead of big one.
Code:
.code
   Main:
..data Somearg db 0    ;I mark it by extra dot
   .submain:
    

As my macro include source additional times for each global section I just skip the body of ..data subsection for wrong sections.
Post 05 Aug 2022, 21:32
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:  
Goto page 1, 2  Next

< 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.