flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Conditional defines?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 08:03
This doesn't compile. Sad

Please tell me how to fix it..

Code:
if foo eq      1
   bar =   "blah"
else if foo eq      2
   bar =   1,2,3
else
       bar =   0
end if

foo  equ     2
db bar    
Post 19 Aug 2009, 08:03
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 19 Aug 2009, 09:22
maybe place foo equ 2 before if
Post 19 Aug 2009, 09:22
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 09:28
Hmm. Actually.. it does compile in the example I gave. But it compiles wrong (to 0x0 instead of 0x010203). If I move the equ to the top it doesn't compile at all. Why is this? I thought that equs were parsed before ifs (which is why I use = instead of equ to set bar).. but were that the case it wouldn't matter whether the "foo equ 2" was at the top or bottom.


Now I'm even more confused. Confused
Post 19 Aug 2009, 09:28
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20417
Location: In your JS exploiting you and your system
revolution 19 Aug 2009, 12:43
You can't define symbols later in the source. This doesn't work:
Code:
display foo
foo     equ     1    


Also you can't assign bar = "blah", you will need to use bar equ "blah". This mean that you also have to use match to process the bar equ.
Code:
foo equ 2
bar equ   0
match foo,1 {bar equ "blah"}
match foo,2 {bar equ 1,2,3}
db bar    
Post 19 Aug 2009, 12:43
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 21:20
Thanks, but it doesn't work.

Code:
foo equ 2 
bar equ   0 
match foo,2 {bar equ 1,2,3} 
match foo,1 {bar equ "blah"} 
db bar    
Outputs "blah". Sad




Code:
bar equ   0 
match foo,2 {bar equ 1,2,3} 
match foo,1 {bar equ "blah"} 
db bar    
Shouldn't even compile.. but outputs "blah". Sad




Please help.. the method you posted has exactly the same problems as the one I originally posted..
Post 19 Aug 2009, 21:20
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 19 Aug 2009, 21:47
Code:
foo equ 2
bar equ 'INVALID'
match =2,foo {bar equ '1','2','3'}
match =1,foo {bar equ "blah"}
display bar    
Post 19 Aug 2009, 21:47
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 21:50
Thank you Very Happy it works.
Post 19 Aug 2009, 21:50
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number 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.