flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Unable to compile code |
Author |
|
Tomasz Grysztar 25 Aug 2021, 20:47
There is a very recent thread about this: https://board.flatassembler.net/topic.php?t=21977 (it applies to fasm g as well as fasm 1, they both handle it the same way).
|
|||
25 Aug 2021, 20:47 |
|
Overclick 26 Aug 2021, 07:30
Quote:
Why don't you fix this for intuitive logic? A lot of macro ideas just stack for this issue. I know how to avoid some of it but isn't it better to use it as it must to be used? |
|||
26 Aug 2021, 07:30 |
|
revolution 26 Aug 2021, 08:20
We can make a macro to simulate the redefinition:
Code: macro default_val var, value { local seen_already if ~ defined var | defined seen_already var = value seen_already = 0 end if } ; seed = 1234 default_val seed, %t db 0xe8 dd seed |
|||
26 Aug 2021, 08:20 |
|
Tomasz Grysztar 26 Aug 2021, 08:54
I should have started with a simpler answer: just use DEFINITE instead of DEFINED, it does exactly what you meant to do here (while DEFINED does not).
Overclick wrote: Why don't you fix this for intuitive logic? A lot of macro ideas just stack for this issue. I know how to avoid some of it but isn't it better to use it as it must to be used? You should use DEFINED when you need to check whether the symbol has a defined value, no mater where, it allows to ensure that you can use it (because you can use a symbol through forward reference even if it is defined later). And DEFINITE can check whether the symbol has been defined earlier in the source, what you might need to check before trying to define it again. They are logically different checks and both are needed - though in a language not having forward-references they would be one and the same. This is perhaps the reason why "if ~ defined" in fasm may appears counterintuitive - because having unrestricted ability to refer to symbols no matter whether they are declared later is perhaps unusual. But this is one of the cornerstones of fasm's language and one of its strengths, and you may notice that when I designed fasmg as a successor, I doubled down and went even further - there you can forward-reference almost anything, including macros of output content. |
|||
26 Aug 2021, 08:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.