flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Can I assign result of condition? |
Author |
|
Jin X 14 Oct 2019, 12:14
Can I realize something like
Code: a = (b <> 0) another way than: Code: if b a = 1 else a = 0 end if ??? More compact. |
|||
14 Oct 2019, 12:14 |
|
revolution 14 Oct 2019, 15:04
The equals (=) character serves both as an operator and an assignment.
So this code would be ambiguous: Code: if a = b ;logical comparison or numeric assignment? I think if you wanted to allow logical conditions to generate a numeric value then you might want to introduce a separate operator. C uses == for comparison, and = for assignment. And you have probably seen how much confusion that has caused over the years. Especially since C also implicitly evaluates assignments. |
|||
14 Oct 2019, 15:04 |
|
Tomasz Grysztar 14 Oct 2019, 15:09
revolution wrote: I think if you wanted to allow logical conditions to generate a numeric value then you might want to introduce a separate operator. C uses == for comparison, and = for assignment. And you have probably seen how much confusion that has caused over the years. Especially since C also implicitly evaluates assignments. |
|||
14 Oct 2019, 15:09 |
|
revolution 14 Oct 2019, 15:28
This might work:
Code: a ← (b <> c) Also use a binary operator to coerce logical to numeric conversion: Code: if a * (b <> c) > d ;use a binary operator to coerce logical to numeric conversion |
|||
14 Oct 2019, 15:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.