flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > if defined A, if A eq...

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4166
Location: 2018
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 iem.design
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: 16101
Location: Squiddler's Patch
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: 4166
Location: 2018
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: 16101
Location: Squiddler's Patch
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


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.