flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > [fasmg] conditional assembly |
Author |
|
revolution 16 Aug 2021, 12:57
This is the standard oscillating problem.
At line 2, the if Pass 1: LINUX_GLIBC not defined, so it gets defined for the next pass. Pass 2: LINUX_GLIBC is defined so it never gets defined for the next pass. Pass 3: Same as pass 1. Pass 4: Same as pass 2. etc... See the link for more detail and explanation. |
|||
16 Aug 2021, 12:57 |
|
sylware 16 Aug 2021, 13:36
Ok, I have to keep in mind this multi-pass oscillating thingy then.
I guess I need to write "pass idempotent" configuration instructions. |
|||
16 Aug 2021, 13:36 |
|
bitRAKE 16 Aug 2021, 14:05
The trick ...
Code: ; define LINUX_GLIBC 0 ; test if ~defined LINUX_GLIBC restore LINUX_GLIBC define LINUX_GLIBC 1 end if ; or this works too ... ;match =LINUX_GLIBC,LINUX_GLIBC ; restore LINUX_GLIBC ; define LINUX_GLIBC 1 ;end match if LINUX_GLIBC display 'blahblah',0x0a end if _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Aug 2021, 14:05 |
|
bitRAKE 16 Aug 2021, 14:25
Here is another way ...
Code: ;define LINUX_XLIBC 0 ; test if defined LINUX_XLIBC & LINUX_XLIBC < __LINE__ else LINUX_XLIBC equ __LINE__ end if if LINUX_XLIBC display 'value > 0',10 end if |
|||
16 Aug 2021, 14:25 |
|
Tomasz Grysztar 16 Aug 2021, 16:49
There is a thread about the pitfalls of "optimistic" multi-pass assembly, where I attempted to explain why such problems happen and how to deal with them.
The solution using RESTORE works because the use of this directive disables forward-reference on that variable. But the recommended method would be to just use DEFINITE operator instead of DEFINED, since DEFINITE directly implies that forward references should not be used. However, for DEFINITE to work correctly there, it should be used with symbol defined numerically, with directives like "=", not DEFINE/EQU, because symbolic substitutions happen before the IF condition is evaluated. If you do "define LINUX_GLIBC 1", then "if ~ defined LINUX_GLIBC" becomes "if ~ defined 1" through text substitution and is evaluated as such. A better option would then be to make it "LINUX_GLIBC := 1" and "if ~ definite LINUX_GLIBC". |
|||
16 Aug 2021, 16:49 |
|
Tomasz Grysztar 16 Aug 2021, 16:49
bitRAKE wrote: (This might be a bug, but I am not going to say anything. Then again it might be because __LINE__ is a variable. Works with other variable terms like $, too.) Code: ;define LINUX_XLIBC 0 ; test if defined LINUX_XLIBC & LINUX_XLIBC < 1 else LINUX_XLIBC equ 1 end if if LINUX_XLIBC display 'value > 0',10 end if |
|||
16 Aug 2021, 16:49 |
|
sylware 18 Aug 2021, 13:58
It seems the less convoluted way to work with multi-pass assembly for this to work is to use ":=" and "definite".
Or maybe there is a more elegant and "fasmg way" to acheive this? |
|||
18 Aug 2021, 13:58 |
|
bitRAKE 18 Aug 2021, 14:38
Tomasz Grysztar wrote: the recommended method would be to just use DEFINITE operator instead of DEFINED, since DEFINITE directly implies that forward references should not be used. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
18 Aug 2021, 14:38 |
|
Tomasz Grysztar 18 Aug 2021, 14:53
bitRAKE wrote: Even in non-numerical situations a numerical flag could be set and used with DEFINITE. |
|||
18 Aug 2021, 14:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.