flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [SOLVED]Fasm1: how to prevent definition

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 10 Dec 2019, 08:02
how to prevent definition of one of label in macro test if same label defined in macro test2?:
Code:
macro test name,[label,string] {
        if used label
                if ~ defined delayed.#label
                        label dd 0
                end if
        end if }

macro test2 name,[label,string] {
        if used label
                delayed.#label:
                        label dd 0
        end if }    
Code:
virtual at 0
dd start,finish
end virtual

test dummy,start,,\
           finish

test2 dummy,start     


thanks.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 10 Dec 2019, 10:06; edited 1 time in total
Post 10 Dec 2019, 08:02
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 10 Dec 2019, 09:56
The problem here is that fasm 1 terminates assembly when it sees a duplicate label error (your method would work correctly with fasmg, where all errors are delayed and resolvable). So you need to add additional check to prevent defining the label twice in the same pass:
Code:
macro test name,[label,string] {
        if used label
                if ~ defined delayed.#label
                        label dd 0
                end if
        end if }

macro test2 name,[label,string] {
        if used label
                delayed.#label:
                if ~ definite label
                        label dd 0
                end if
        end if }    
Post 10 Dec 2019, 09:56
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 10 Dec 2019, 10:05
Thanks Tomasz.
definite is realy solves problems that were unrosolvable before.
Post 10 Dec 2019, 10:05
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 10 Dec 2019, 10:15
This could be solved without DEFINITE as well, just a bit more complex:
Code:
macro test name,[label,string] {
        if used label
                if ~ defined delayed.#label
                        undelayed.#label:
                        label dd 0
                end if
        end if }

macro test2 name,[label,string] {
        if used label
                delayed.#label:
                if ~ defined undelayed.#label
                        label dd 0
                end if
        end if }    
Post 10 Dec 2019, 10:15
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.