flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > preprocessor , get the first equ definition?

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 24 Feb 2023, 18:48
how is it possible to make it work?

Code:
VALUE equ "value is pre overriden"

if ~defined VALUE
VALUE equ "value is now defined"
end if


db VALUE,0

    
Post 24 Feb 2023, 18:48
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 804
Location: Russian Federation, Sochi
ProMiNick 24 Feb 2023, 19:53
Code:
value equ "value is pre overriden"

irpv v, value { common temp equ }
match =temp,temp { value equ "value is now defined" }
restore temp

db value,0     
Post 24 Feb 2023, 19:53
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: 20451
Location: In your JS exploiting you and your system
revolution 24 Feb 2023, 20:57
You don't need irpv. And temp is not an assignment and doesn't require restore.
Code:
value equ "value is pre overriden"

match =value,value { value equ "value is now defined" }

db value,0    
Post 24 Feb 2023, 20:57
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 25 Feb 2023, 14:07
Thanks!!!

yess! then if i undestand well, =operator before the A argument of match is a not.
and then, match will preproc when value is not value.

it is not clearly documented in the fasm doc.
Quote:

To match any other symbol literally, it has to be preceded by = character in the
pattern. Also to match the = character itself, or the comma, the == and =, constructions
have to be used. For example the =a== pattern will match the a= sequence.

maybe an example for this part would be interresting as there are a lot of usecases where we need to do this kind of stuff.
Post 25 Feb 2023, 14:07
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: 20451
Location: In your JS exploiting you and your system
revolution 25 Feb 2023, 14:35
If 'value' has no existing definition then the part after the comma is simply itself and the match succeeds.

If 'value' has been defined then the part after the comma is replaced.
Code:
value equ foo
match =foo, value { display "I am a match because 'foo' == 'foo'",13,10 }
match =foo, foo { display "I am a match because 'foo' == 'foo'",13,10 }
match =value, value { display "you never see me because 'value' != 'foo'",13,10 }
match =value, foo { display "you never see me because 'value' != 'foo'",13,10 }    
Post 25 Feb 2023, 14:35
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 804
Location: Russian Federation, Sochi
ProMiNick 25 Feb 2023, 17:42
Code:
value = 4
value equ value
value equ value
irpv v, value { \common display "value is at least once overrided",13,10 }
irpv v, value { display "count of this message is displayed is equal count of value overridings,13,10 }
irpv v, foo { \common display "you never see me because foo is never overrided",13,10 }    

value is overrided but still
Code:
match =value, value { display "you will see me too'",13,10 }    

so this is not property of absence of override or absence of value that could be assembled
Code:
dd value; assembled with no error,no matter than match =value,value    
Post 25 Feb 2023, 17:42
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 26 Feb 2023, 12:14
right

i tested with an undefined constant, it don't works as i expected. match is a hard to understand directive.


in this code, i want to define A, B, C and D only when value is defined.
the equ after value should match the pattern of the macro.
in this example, there is not check of pattern, but it works when value is defined.
Code:

macro _value a,b,c,d {
A=a
B=b
C=c
D=d
}

match value,value {
 _value value
}

    
Post 26 Feb 2023, 12:14
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.