flat assembler
Message board for the users of flat assembler.

Index > Main > EQU inside if...else...end

Author
Thread Post new topic Reply to topic
AL-CHEMIST



Joined: 16 Nov 2009
Posts: 3
Location: Russia
AL-CHEMIST 07 May 2023, 00:36
Code:
something equ 1
if something eq 1
else
end if
xdi
; xdi EQ xdi
; OK
    

Code:
something equ 1
if something eq 1
 xdi equ rdi
else
end if
xdi
; xdi EQ rdi
; OK
    

Code:
something equ 1
if something eq 1
 xdi equ rdi
else
 xdi equ edi
end if
xdi
; xdi EQ edi
; ??? xdi NOT EQ rdi
    

Code:
something equ 1
if something eq 1
else
 xdi equ edi
end if
xdi
; xdi EQ edi
; ??? xdi NOT EQ xdi
    


Why so?
Post 07 May 2023, 00:36
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1143
Location: Russia
macomics 07 May 2023, 07:00
equ - preprocessor
if .. else .. end if - assembler
To control conditional assignment of values by equ, you need to use match instead of if .. else .. end if.
Post 07 May 2023, 07:00
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1933
Roman 07 May 2023, 10:23
Quote:
if .. else .. end if - assembler

How about if in match ?
Code:
match x , something {
if x = 1
end if
)
    
Post 07 May 2023, 10:23
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1143
Location: Russia
macomics 07 May 2023, 10:43
Roman wrote:
How about if in match ?
Code:
define something 1
define some_else 2
match x , something {
if x = 1
define a 5
end if
display `x, 13, 10
match u, a \{ display \`u, 13, 10 \}
}
match x , some_else {
if x = 1
define b 4
end if
display `x, 13, 10
match u, b \{ display \`u, 13, 10 \}
}    
-preprocessor>
Code:
; define something 1
; define some_else 2
; match x, something {
if 1 = 1
; define a 5
end if
display '1', 13, 10
; match u, a \{
display '5', 13, 10
; \}
;}
; match x, some_else {
if 2 = 1
; define b 4
end if
display '2', 13, 10
; match u, b \{
display '4', 13, 10
; \}
;}
    
-assembler>
Code:
if 1 = 1 ; true
end if
display '1', 13, 10 ; show 1
display '5', 13, 10 ; show 5
if 2 = 1 ; false
end if
display '2', 13, 10 ; show 2
display '4', 13, 10 ; show 4    


Code:
$ fasm main.asm -m 64
flat assembler  version 1.73.30  (64 kilobytes memory)
1
5
2
4
1 passes, 0 bytes.    
Post 07 May 2023, 10:43
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.