flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > if defined A, if A eq...

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4150
Location: https://pastebin.com/Vw7WXXf4
if defined A, if A eq...
this code

Code:

A equ 'A'

if ~defined A
A equ 'B'
end if

display A

if A eq 'A'
A equ 'C'
end if

display A    



give me 'BC' as output, but what i want is 'AC'

there, i don't get why the first if don't detect the previous A definition, and then, i don't know why the second if detect the A to be 'A'

_________________
Smile fool
Post 23 Sep 2016, 18:23
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: 15156
Location: GW170817
The preprocessor is completely blind to the assembly lines. So the preprocessor sees this:

Code:

A equ 'A'

;if ~defined A
A equ 'B'
;end if

;display A

;if A eq 'A'
A equ 'C'
;end if

;display A

It makes no difference what the "if" statements evaluate to, the "equ" is always assigned.
Post 23 Sep 2016, 18:26
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4150
Location: https://pastebin.com/Vw7WXXf4
i was quite sure of this, but did not find this in the doc. Wink

note: display works
Post 23 Sep 2016, 18: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: 15156
Location: GW170817
display is processed at assembly time, after all the equs. The assembler see this:

Code:
;A equ 'A'

if ~defined 'A'
;A equ 'B'
end if

display 'B'

if 'B' eq 'A'
;A equ 'C'
end if

display 'C'

Post 23 Sep 2016, 18:41
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.