flat assembler
Message board for the users of flat assembler.

Index > Main > Conditional inclusion: MATCH and definitions ?

Author
Thread Post new topic Reply to topic
james



Joined: 07 Sep 2005
Posts: 45
Location: Australia
james
In FASM you can do conditional inclusion of things.
eg:

Code:
match =TRUE, DEBUG { include 'debug.inc' }    


Can someone tell me how to define DEBUG outside fo the source ?

Do I need to set an environment variable ?

My goal is to 'define' outside of the source so that when the source is
assembled (preprocessed) it will conditionally include files.

rgs, James
Post 10 Sep 2005, 23:40
View user's profile Send private message MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you can't define equates externally, this was already discussed somewhere on board. FASM's philosophy is that contents of generated file depends ONLY on contents of source file. It's quite easy to define it somewhere by the beginning of file.
Post 11 Sep 2005, 09:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
james



Joined: 07 Sep 2005
Posts: 45
Location: Australia
james
Vid,
thanks, but then its not conditional.
No need for match then.

rgs, james.
Post 11 Sep 2005, 20:46
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
You can have environment variable with the name of include file, like DEBUG=debug.inc or DEBUG=nul, and then include it like:
Code:
include '%DEBUG%'    
Post 11 Sep 2005, 21:42
View user's profile Send private message Visit poster's website Reply with quote
james



Joined: 07 Sep 2005
Posts: 45
Location: Australia
james
Tomasz,

Setting an environment variable seems a little much when trying to do
conditional preprocessing.

I was hoping you could do a "-d os=win32" on the command line and
then in code do a

Code:
match =win32, OS { include 'win32ax.inc' }    


This seems to be a defacto standard approach, but I appreciate FASM is different and "flat".

I can get around this with a batch (.bat) file and a shell script (.sh) but it
doesnt seem as elegant.

BTW Tomasz, any chance of an example source to making a shared library under linux ?

Rgs, James.
Post 12 Sep 2005, 04:26
View user's profile Send private message MSN Messenger Reply with quote
james



Joined: 07 Sep 2005
Posts: 45
Location: Australia
james
Can anyone show a working example using match ?
Post 02 Oct 2005, 03:06
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17340
Location: In your JS exploiting you and your system
revolution
You can also use something like this:

File MyApp-osWIN32.asm:
Code:
OS equ WIN32
include "MyApp.asm"    

File MyApp-osLINUX.asm
Code:
OS equ LINUX
include "MyApp.asm"    

File MyApp-osWIN32-debug.asm:
Code:
OS equ WIN32
DEBUG equ TRUE
include "MyApp.asm"    

File MyApp-osLINUX-debug.asm
Code:
OS equ LINUX
DEBUG equ TRUE
include "MyApp.asm"    

File MyApp.asm:
Code:
match =WIN32,OS {;stuff for win32 goes here}
match =LINUX,OS {;stuff for linux goes here}
match =TRUE,DEBUG {;debugging stuff goes here}    
Post 02 Oct 2005, 06:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17340
Location: In your JS exploiting you and your system
revolution
Also try this:

File FASM-debug.bat:
Code:
@echo DEBUG equ TRUE >FASM-debug.abc
@echo include '%1.asm' >>FASM-debug.abc
@fasm FASM-debug.abc %1.exe
@del FASM-debug.abc    
Post 02 Oct 2005, 06:16
View user's profile Send private message Visit poster's website Reply with quote
james



Joined: 07 Sep 2005
Posts: 45
Location: Australia
james
thanks for the examples. They help me a lot.
Post 02 Oct 2005, 06:54
View user's profile Send private message MSN Messenger 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.