flat assembler
Message board for the users of flat assembler.

Index > Main > FASM define macro from commmand line - "-d" switch

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7571
Location: Kraków, Poland
Tomasz Grysztar
l_inc wrote:
As you already explained, it's just a matter of definition whether you call something a part of a source or not. Hence the elusive meaning of the SSSO principle was probably a wrong motivation, but I think removing the "-d" switch wasn't such a bad idea, because this discouraged rather inappropriate organizations of source code. Bringing the switch back again not only makes it possible but also encourages.

Or do you just disagree that it's much better to have different base files for different configurations (or a separate editable config.inc for other use cases) rather than to have in mind some unobvious possible configurations definable by putting something into the command line?
I think that in practice the availability of "-d" did not really had a large effect. Even without "-d" one could write in the comment on top of his sources that "you need to define such and such constant to get it to assemble this way". And when someone forgets to write such comment, the errors caused by a lack of definition are usually easy to catch. If I get the source that fails to compile because it uses some variable that is not defined anywhere, my first reflex is to add a definition on top of the source. The "-d" switch adds an additional way to do that, but it is usually less obvious and less convenient. So I think that the encouragement of bad practices caused by "-d" is actually quite small. I think it is only really useful to people that need it in the scripts that mix fasm with other command line tools, and such projects have a much wider "source" (with files in many different languages) anyway.
Post 04 Jan 2015, 17:56
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Tomasz Grysztar
Okay. Smile

_________________
Faith is a superposition of knowledge and fallacy
Post 04 Jan 2015, 18:04
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
Code:
version 1.71.32 (Jan 04, 2015)

[+] Brought back the "-d" switch for command line.

version 1.71.31 (Dec 08, 2014)    


WOW: "-d" added (untested).

Quote:
The features like FORMAT do encourage to create self-sufficient sources. On the other hand, the removal of "-d" was an attempt at enforcing this, and in my opinion it was doomed to fail because by the same reasoning not only use of environment variables or time stamp, but even the INCLUDE directive in itself could be removed from language, and this never even crossed my mind


Very good point. See also: https://gitian.org/

Quote:
Gitian uses a deterministic build process to allow multiple builders to create identical binaries.


By the way, I always deprecated INCLUDE (because it's much more evil than "-d"), linkers, and even "format PE".
Post 06 Jan 2015, 07:18
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
But how -D switch will affect FASMW (well and Fresh)?
Is it means that if there is a project that needs such definitions in the command line, it will not be possible to be compiled with FASMW?
Post 06 Jan 2015, 08:48
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7571
Location: Kraków, Poland
Tomasz Grysztar
JohnFound wrote:
Is it means that if there is a project that needs such definitions in the command line, it will not be possible to be compiled with FASMW?
Such definition is not different from putting the "define" in the beginning of source and if any project requires such definition, it is still more natural (IMO) to add a new line to the source instead - this was the point in the above discussion. The command line switch is more useful only in the case of automated build scripts that combine works of various tools/compilers (there only the command-line version of fasm is applicable). When you assemble from fasmw, you assemble the pure fasm's project and then modifying "define" lines on top of the source is a simple and intuitive way of obtaining the same result.
Post 06 Jan 2015, 10:24
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Tomasz Grysztar wrote:
JohnFound wrote:
Is it means that if there is a project that needs such definitions in the command line, it will not be possible to be compiled with FASMW?
Such definition is not different from putting the "define" in the beginning of source and if any project requires such definition, it is still more natural (IMO) to add a new line to the source instead - this was the point in the above discussion. The command line switch is more useful only in the case of automated build scripts that combine works of various tools/compilers (there only the command-line version of fasm is applicable). When you assemble from fasmw, you assemble the pure fasm's project and then modifying "define" lines on top of the source is a simple and intuitive way of obtaining the same result.


Yes, I understand that. But the fact is that now it is possible to have source that can't be compiled in FASMW without editing. (Of course with some editing, even MASM source can be compiled.)

On the other hand, if I include these define statements at the beginning of the source file, they will always override these defined by -D command line option, making the later useless.

Also, IMO, the loose definition of "source" is contradictory. Following it, we are coming to something that can be "source" for console FASM, but "not source" for GUI FASM versions.

So, IMHO, -D option is very, very controversial feature.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 06 Jan 2015, 10:45
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17010
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
So, IMHO, -D option is very, very controversial feature.
Hehe, déjà vu. Razz
revolution wrote:
It was [a] controversial feature ...
Post 06 Jan 2015, 10:54
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: 17010
Location: In your JS exploiting you and your system
revolution
More seriously, things like VS "solve" this with project definition files that contain all the extra things, like command line options, needed to get a successful build. Naturally these files tend to be unique to each IDE and not very portable. The common alternative to that is the makefile.
Post 06 Jan 2015, 10:57
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
JohnFound wrote:
if I include these define statements at the beginning of the source file, they will always override these defined by -D command line option

Btw. overriding is one more good thing to discuss with respect to its effect on the symbolic constant stacks.

_________________
Faith is a superposition of knowledge and fallacy
Post 06 Jan 2015, 14:25
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7571
Location: Kraków, Poland
Tomasz Grysztar
JohnFound wrote:
Also, IMO, the loose definition of "source" is contradictory. Following it, we are coming to something that can be "source" for console FASM, but "not source" for GUI FASM versions.
This is the problem I pointed out above because it makes "same source, same output" a wrong formulation of my original idea, since it requires a wider and more arbitrary definition of "source" to somehow reconcile it with existence of INCLUDE features, etc. I don't really want to create such convoluted rationales, so I withdraw to a more basic position: that fasm gives the tools to create self-sufficient sources and encourages to create programs this way, without wasting resources to try to convince everyone that this is the one and only correct way for every possible application.
Post 06 Jan 2015, 15:48
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
IMO, whatever the definition of "source" is, it must be the same for all versions of FASM. But this is not the case with -D option.

Also, notice the point of l_inc about the symbolic constant stack.

Generally speaking, I have a feeling that -D option introduces a big amount of chaos in the FASM behavior.

Also, it has some architectural problems: The implementation of this option is not in the compiler itself, but in the interface code. This way, the OS dependent interface can influent the work of the compiler in a way that is not well specified and is different for the different implementations. (because the command line options are useful only for the CLI versions of FASM). For the GUI versions, equivalent feature will need handling of some project file format (as revolution said), containing these special constants definitions.

And as a last (for now) argument: the Occam's razor and KISS principle: Everything that can be done with -D option can be done without it as well. So, -D option Considered Harmful Wink
Post 06 Jan 2015, 17:58
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
JohnFound
Quote:
Also, notice the point of l_inc about the symbolic constant stack

IMHO the "-d" option (if it's there) should work the same way as if there was a declaration of the corresponding constant at the very beginning of the source. I.e. the overriding is done in the normal way of adding the new value to the already existing stack instead of creating a new clean one. Otherwise the "-d" option introduces side effects otherwise not achievable (bad thing) instead of making the existing things simpler for some use cases. I didn't check the newest fasm version yet, but I'm quite sure, it's done the better way.

Quote:
Everything that can be done with -D option can be done without it as well

Which is good. But a bare possibility of doing some things is normally not as good as simplicity of doing the same things. So maybe the "-d" option to the contrary allows to follow KISS/Occam by avoiding some additional aspects. Such as creating/modifying an additional file with options during automatic compilation process.

P.S. However I'm completely against an architecture that allows to do a thousand slightly different things by providing a thousand separate ways for each of those similar things specifically.

_________________
Faith is a superposition of knowledge and fallacy
Post 06 Jan 2015, 18:15
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7571
Location: Kraków, Poland
Tomasz Grysztar
JohnFound wrote:
IMO, whatever the definition of "source" is, it must be the same for all versions of FASM. But this is not the case with -D option.
My point was that the whole idea of defining what constitutes a "source" was flawed. With a DLL version of fasm, or fasm ported to OS that has no traditional file system, the source is going to be just some text in memory buffer; in OS that has case insensitive file system the INCLUDE may give different results than in the one where file names are case sensitive, etc. There are many differences in how various ports of fasm ("interfaces" in fasm's nomenclature) may provide the input into the assembler's core, and "-d" is just another one (probably only useful for command-line interfaces in POSIX-like systems).

l_inc wrote:
IMHO the "-d" option (if it's there) should work the same way as if there was a declaration of the corresponding constant at the very beginning of the source. I.e. the overriding is done in the normal way of adding the new value to the already existing stack instead of creating a new clean one.
Yes, all that "-dx=y" does is equivalent to adding a "define x y" line on top of the source. This really is just one additional method of creating input for fasm's preprocessor, in this case without the agency of file system. My revised principle leads to rules like this: in whatever way the source is built, it is possible to have a completely equivalent source as a simple continuous text (a single file, or single memory buffer). The equivalence in this case leading automatically to the same output.
Post 06 Jan 2015, 19:09
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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.

Powered by rwasa.