flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with EQU in conditional compilation

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello,

I have the following example:

----

Code:
DEFINE_YEAR = 1


IF DEFINE_YEAR 

    pyear  EQU 'ok'

ELSE

    pyear  EQU 'error_error_error'

END IF 


mov     eax, pyear    


-----

When I compile it, I get error as "eax" is assigned "error_error_error"!!!

How can that be if the condition DEFINE_YEAR is 1?

Thanks!
Post 13 Oct 2009, 18:28
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
That is because the preprocessor doesn't see the assembler stage IF-ELSE.

If you can change DEFINE_YEAR to "DEFINE_YEAR equ 1" or even "DEFINE_YEAR equ yes" then you could do this:
Code:
DEFINE_YEAR equ yes

match =yes, DEFINE_YEAR{pyear EQU 'ok'}
match =no, DEFINE_YEAR{pyear equ 'error_error_error'}

mov eax, pyear ; You'll get an error with "DEFINE_YEAR equ no", though.    
Post 13 Oct 2009, 18:42
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
You may want to check out the fourth question in FAQ, too.
Post 13 Oct 2009, 18:59
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks a lot!!! It works great with "match" approach Wink

Thanks Tomasz for the link, I was reading through all docs by I might have missed that Smile
Post 13 Oct 2009, 19:57
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.