flat assembler
Message board for the users of flat assembler.

Index > Main > /D switch for FASM?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
weiss



Joined: 03 Jan 2006
Posts: 25
weiss 19 Jan 2007, 14:06
I've always wanted to write a program which with a simple switch could allow the code to assemble on another operating system.
Obviously, i'm talking about Linux/Windows compatible software..
this is possible using C library functions.

something like:

if defined LINUX
format ELF
else
format PE
endif

then with command line.

fasm /DLINUX code.asm

will this feature be added in future?
Post 19 Jan 2007, 14:06
View user's profile Send private message Reply with quote
donkey7



Joined: 31 Jan 2005
Posts: 127
Location: Poland, Malopolska
donkey7 19 Jan 2007, 15:08
it was discussed before and disapproved.

read:
http://flatassembler.net/docs.php?article=design
chapter '3. Same Source, Same Output'

instead you can create two files.

windows.asm:
Code:
LINUX = 0
include 'main.asm'
    

linux.asm:
Code:
LINUX = 1
include 'main.asm'
    


this would be even easier for noobs to compile ;]
Post 19 Jan 2007, 15:08
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 19 Jan 2007, 15:44
What about something like settings.inc file, where the text macro would be defined?
settings.inc wrote:

LINUX EQU
;WINDOWS EQU

Code:
include settings.inc

if defined LINUX
format ELF
else
format PE
endif 
    

It is just a silly example. It can be improved so that you can edit the settings file automatically using, for instance, some batch before the asm file gets actually compiled.
Post 19 Jan 2007, 15:44
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 19 Jan 2007, 16:18
Not wanting to add a /D is a bit silly, imho - you can work around it using environment variables, which is even uglier.
Post 19 Jan 2007, 16:18
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 19 Jan 2007, 20:29
Right now, the only thing that prevents FASM code from compiling is using a different version (e.g., ## becomes \# or whatever). This is rare, and not a big deal. If more cmdline options are added, it will definitely complicate the process. Once you let in one, it's a slippery slope from there.

Quote:

Why not /U? But /D is already there! Also, /P and /I and /L and everything that every other assembler does. But FASM should comply! Resistance is futile!


Seriously, it's just easier the way it is.
Post 19 Jan 2007, 20:29
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 19 Jan 2007, 22:45
*shrug*

just seems silly to me to not support a feature that'd make certain things easier without kludgy workarounds or code duplication.
Post 19 Jan 2007, 22:45
View user's profile Send private message Visit poster's website Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 204
ACP 04 Feb 2007, 19:03
f0dder wrote:
*shrug*

just seems silly to me to not support a feature that'd make certain things easier without kludgy workarounds or code duplication.

I agree - there is no point in using tricks just to accomplish simple task.
Post 04 Feb 2007, 19:03
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 05 Feb 2007, 16:38
I disagree. Using a "setup file" seems cleaner to me. I don't think it's a workaround.
Post 05 Feb 2007, 16:38
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Feb 2007, 17:23
this feature can come handy sometimes (external configs), and annoying other times (compilation problems). Generally, now i wouldn't mind if it was present.

It is not very needed for FASM style of coding, where entire project is always compiled. There you have multiple main files, one for each version, and it works. But if you change coding style to having many files compiled to objects and linked together, this gets annoying.
Post 05 Feb 2007, 17:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 05 Feb 2007, 20:01
Any particular reason to use FASM (which lacks this) over YASM? (It supports x86-64, so I'm guessing incompatible macros.)
Post 05 Feb 2007, 20:01
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Feb 2007, 21:21
don't forget FASM "lacks" this on purpose, gaining something else.

To me FASM seems somewhat neater to use... try both and decide for yourself.
Post 05 Feb 2007, 21:21
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 07 Feb 2007, 01:07
Quote:

particular reason to use FASM (which lacks this) over YASM


YES:


  • Simplicity of usage
  • Self-compilable
  • DOS version incl. IDE - does YASM work in DOS at all ?
  • format MZ
  • Yasm can be easily integrated into Visual Studio 2005 Sad


Quote:

switch could allow the code to assemble on another operating system.


NOT amused. But instead, one could allow 1 ( ONE ) constant to be
set from cmdline:

Code:
FASM HELLO.ASM /D:OS=2
    


Code:
OS = 1 ; default
if OS = 1
format PE
else
format MZ
endif  
    


Just ^^^ an idea Idea

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 07 Feb 2007, 01:07
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 07 Feb 2007, 10:16
Who cares about DOS? You could always use WDOSX or Japheth's HX anyway.

NTOSKRNL_VXE wrote:

Yasm can be easily integrated into Visual Studio 2005 Sad

Why the sad smiley?

_________________
Image - carpe noctem
Post 07 Feb 2007, 10:16
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Feb 2007, 10:58
i think there was some integration of FASM to VS2005 some time ago.
Post 07 Feb 2007, 10:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 07 Feb 2007, 13:51
Yes, YASM works in DOS (see snapshots). It's not exactly useless: it does some things FASM doesn't (e.g., GAS parser).

What I meant was: since FASM probably won't have /D any time soon, why not consider using YASM? (Not necessarily realistic, but who knows, maybe your code ain't too FASM specific).
Post 07 Feb 2007, 13:51
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Feb 2007, 16:17
Some YASM sources can even be "ported" just by compiling with different file format, without any extra effort in sources. But that requires portable library with defined ABI, it is sometimes problem with libc.

But FASM still has better design than NASM/YASM.
Post 07 Feb 2007, 16:17
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Japheth 07 Feb 2007, 18:20
> But FASM still has better design than NASM/YASM.

Might be, but at least they support creating debugging info, listings and OMF output format (NASM, YASM is just about to - hopefully - support this important feature). In FASM I still don't find such things. Are they regarded as unimportant/obsolete by most FASM users?
Post 07 Feb 2007, 18:20
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 07 Feb 2007, 20:56
I think the main problem is Privalov's lack of free time. (He's already stated much interest in creating his own debug format as well as possible Mach-o support.)

FASM and YASM are both good tools to use if they do what you want.

(A good example of NASM/YASM code that assembles correctly for multiple file formats is PAQ8? by Matt Mahoney.)
Post 07 Feb 2007, 20:56
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Feb 2007, 21:24
Quote:
Might be, but at least they support creating debugging info, listings and OMF output format (NASM, YASM is just about to - hopefully - support this important feature). In FASM I still don't find such things. Are they regarded as unimportant/obsolete by most FASM users?

debugging info is regarded unimportant by tomasz Wink
push on him Wink
Post 07 Feb 2007, 21:24
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 07 Feb 2007, 23:21
Quote:
Who cares about DOS?


ME. And Tomasz maybe Shocked

Quote:
or Japheth's HX anyway


Sorry I know this Shocked I am probably the hardest-core user of it Laughing

Quote:
Why the sad smiley?


Well, this "Studio":

- Is it useful ?
- Benefits ?
- Works anywhere except in XP SP2 ?
- Size ?
- Legal download ?
- Usable license ?

Quote:
Yes, YASM works in DOS (see snapshots


OK, existenbce of a DGJPP or "DGJPP-MSDOS" port does NOT
necessarily mean there is a usable DOS version - some of such stuff
does work in DOS, some don't (mostly Page Faults Sad ).

Quote:

Might be, but at least they support creating debugging info, listings and OMF output format (NASM, YASM is just about to - hopefully - support this important feature). In FASM I still don't find such things. Are they regarded as unimportant/obsolete by most FASM users?


- Debug: ??? maybe
- Listing: Right, a neglected thing. Sad A statement from Tomasz would be nice.
- OMF: I see no benefit by now. Having OMF out one still has a hard fight left to link it correctly Confused

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 07 Feb 2007, 23:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.