flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
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. |
|||
![]() |
|
sylware
Ok, I have to keep in mind this multi-pass oscillating thingy then.
I guess I need to write "pass idempotent" configuration instructions. |
|||
![]() |
|
bitRAKE
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 |
|||
![]() |
|
bitRAKE
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 ![]() |
|||
![]() |
|
Tomasz Grysztar
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". |
|||
![]() |
|
Tomasz Grysztar
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 |
|||
![]() |
|
sylware
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? |
|||
![]() |
|
bitRAKE
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. |
|||
![]() |
|
Tomasz Grysztar
bitRAKE wrote: Even in non-numerical situations a numerical flag could be set and used with DEFINITE. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.