flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > label with no value, no namespace but if defined

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 30 Mar 2023, 21:54
i was wondering how it can be possible to make something like this
Code:

thisLabelHaveAValue=1
thisOneAlso:
.thisIsLocalForAlso:
.thisIsLocalTooForAlso=1

butNow:
IwantItToBeALAbelWithoutValue.
.andThisToBeLocalForbutNow:

    


for example, a no value label can be a label ending by a single dot, or anything else.
and now a more readable example:

Code:
Label1=1

mov al,Label2.local6


Label2:
.local1:
        db '1'
.local2=2
.local3.
Global1.
.local4:
Global2.
if defined Global1
.local5=5
end if
.local6 db 6


    


of course, it is just for comfort.
using conventionnal labels is enough, but label with no value can be interresting.
Post 30 Mar 2023, 21:54
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3918
Location: vpcmipstrm
bitRAKE 30 Mar 2023, 22:51
Here I extend the example from the fasmg documentation:
Code:
postpone
namespace GLOBAL
        element NOVALUE
        irpv G,GLOBAL
                label G:NOVALUE at NOVALUE
        end irpv
end namespace
end postpone

struc (head) ? tail&
        match ,tail
                display 10, `head," is NOVALUE"
                define GLOBAL head
                macro ? line&
                        purge ?
                end macro
        end match
        head tail
end struc


dd Main.local_to_main
Main:
        undefined_labels_have_no_value
        IwantItToBeALAbelWithoutValue
        .local_to_main:    
... I put all the undefined labels in a special GLOBAL space so they don't interfere with local labels, and make them variable terms so they can't be used in calculations. Perhaps there is more to your requirements?
Post 30 Mar 2023, 22: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: 20070
Location: In your JS exploiting you and your system
revolution 31 Mar 2023, 00:36
The double dot is for global labels not attached to a preceding label.
Code:
label1:
..global1:
.local1:
..global2:    
Post 31 Mar 2023, 00:36
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 31 Mar 2023, 07:57
revolution wrote:
The double dot is for global labels not attached to a preceding label.
Code:
label1:
..global1:
.local1:
..global2:    

This is work in Fasmw 1.73 too?
Post 31 Mar 2023, 07:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20070
Location: In your JS exploiting you and your system
revolution 31 Mar 2023, 08:34
Roman wrote:
revolution wrote:
The double dot is for global labels not attached to a preceding label.
Code:
label1:
..global1:
.local1:
..global2:    

This is work in Fasmw 1.73 too?
Yes. my answer is for fasm. fasmw is the IDE editor which uses fasm internally, so it will work for fasmw also.

Try it.
Post 31 Mar 2023, 08:34
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 01 Apr 2023, 00:13
cool very cool. i'll use it

but what i suggest is a label withou any value attached to it.

like:

Code:

Global.

mov eax,Global;impossible to do

if defined Global
display 'yes'
end if

if Global=3
impossible to know
end if

Global.;no error even if still defined

if Global eq
display 'yes it exists'
end if


if Global ~eq
impossible to know 
end if
    


something like that.
but of course, the negative conditions are not mandatory. the only condition to have is a label without value attached to it, and global, and reccursive, and don't care if still defined
Post 01 Apr 2023, 00:13
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: 20070
Location: In your JS exploiting you and your system
revolution 01 Apr 2023, 01:39
Assign no value.
Code:
Global =    
What purpose will it serve? Where is it useful?
Post 01 Apr 2023, 01:39
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 909
Location: Russia
macomics 01 Apr 2023, 07:01
Code:
struc global
{   if 0
        label .
    end if
}

Label1=1

mov al,Label2.local6


Label2:
.local1:
        db '1'
.local2=2
.local3 global
Global1 global
.local4:
Global2 global
if defined Global1
.local5=5
end if
.local6 db 6    
Post 01 Apr 2023, 07:01
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 01 Apr 2023, 10:38
it is to have an intuitive and easy to use boolean flag useable during preprocessing.
not the same as

label equ thing
label:
label= thing

cause theses still have a purpose.

Code:
DEBUG:

if DEBUG
mov eax,thing
end if
    


for the moment, the best fit is

label:

but it have a scope, and i don't care the value assinged to it.

and it needs something around to if that

Code:
if defined DEBUG
end if
    
Post 01 Apr 2023, 10:38
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: 20070
Location: In your JS exploiting you and your system
revolution 01 Apr 2023, 11:42
Why must it have no value?
Code:
DEBUG = 0 ; don't want debug
;...
DEBUG = 1 ; gimme the debugs
;...    
Post 01 Apr 2023, 11:42
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 01 Apr 2023, 19:36
I want to put it anywhere, and don't need it to be defined if i don't want it in the code.
if i write a

if VAR

no error and for a

mov eax,var

error cause it is an internal compiler flag

hem.. now it makes all sense, if i don't need a value for a label, how to react to a undefined value...
Post 01 Apr 2023, 19:36
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.