flat assembler
Message board for the users of flat assembler.

Index > Main > Detecting fasm vs fasm2 / writing compatible macros

Author
Thread Post new topic Reply to topic
Ping



Joined: 27 Feb 2026
Posts: 2
Ping 27 Feb 2026, 18:54
Hi all,

Is there a reliable way (at assembly time) to detect whether the source is being assembled by FASM 1.x or FASM2?

I have an .inc file I’d like to reuse with FASM2. Most of it works, but a couple of macros rely on the older macro style and need alternative definitions under FASM2. I’m trying to keep a single shared include if possible.

Specifically:

    - Are there any predefined symbols (e.g., VERSION or similar) in FASM and/or FASM2 that can be tested with if defined ...?

    - If not, is there a recommended pattern for conditional macro definitions / feature detection between FASM1 and FASM2 (or should I require a user-defined switch like -dFASM2=1)?

Any guidance or best-practice examples would be appreciated.

Thanks,
Michael
Post 27 Feb 2026, 18:54
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8506
Location: Kraków, Poland
Tomasz Grysztar 27 Feb 2026, 23:25
Look no further than in the source of fasmg itself:
Code:
match ,{

        ; fasm 1 detected
        include 'win32a.inc'

} match -,{
else

        ; fasm g detected
        include 'selfhost.inc'

end match
_ equ }    
I've been using this trick ever since fasmg started being able to self-host. Some of the fasm2-adapted sources still use it.
Post 27 Feb 2026, 23:25
View user's profile Send private message Visit poster's website Reply with quote
Ping



Joined: 27 Feb 2026
Posts: 2
Ping 28 Feb 2026, 20:08
Tomasz Grysztar wrote:
Look no further than in the source of fasmg itself:
Code:
match ,{

        ; fasm 1 detected
        include 'win32a.inc'

} match -,{
else

        ; fasm g detected
        include 'selfhost.inc'

end match
_ equ }    
I've been using this trick ever since fasmg started being able to self-host. Some of the fasm2-adapted sources still use it.


Thank you, Tomasz!
Post 28 Feb 2026, 20:08
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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.