flat assembler
Message board for the users of flat assembler.

Index > Main > q. about fasm's way of handling output format selection

Author
Thread Post new topic Reply to topic
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
arafel
I was wondering, why the selection of output format is handled from within the source code? Wouldn't it be more practical (for example when using some tools for controlling the compilation process e.g. 'make'.) to choose the output format from command-line?
Post 05 Oct 2006, 18:22
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Design Principles or why flat assembler is different? wrote:
3. Same Source, Same Output

The problem with command line switches selecting output option in case of low level assembly is that the given code will anyway most probably assemble and execute correctly only when the same output is selected that programmer had in mind when writing this code. Also I remembered many cases when I had a source for TASM written by someone other, and to compile it correctly I had to follow the directions given in the comment at the beginning of source and just rewrite all the command line switches as described there. And my though was: then why don't just make assembler look for such options in the source instead, so nobody will have any problem with recompiling. Thus came the SSSO principle - all the settings that can affect the output of assembler are be selected only from source and source is always enough to generate exactly the file which was intented by programmer. The consequence of SSSO idea was also that no matter what version of fasm (considering ports to different operating systems), it always generated the same output file, so when you have written a DOS program, the Linux version of fasm would still make the same DOS executable from such source.

Some people seem to dislike the implications of this principle, because all other assemblers and compilers have the command line settings that affect the output (or even the source constants) and this different approach needs to change a bit the way of thinking in some cases (this actually happens in even more areas when programming with flat assembler, and it's the purpose of this text to show the origin and reason for those differences). The SSSO rule became one of the guidelines for the design of flat assembler and I don't plan to put it away.
Smile
Post 05 Oct 2006, 19:15
View user's profile Send private message Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
arafel
Uh, I see.

Thanks.
Post 05 Oct 2006, 19:26
View user's profile Send private message Reply with quote
f14t



Joined: 27 Sep 2006
Posts: 36
f14t
locodelassembly wrote:
Design Principles or why flat assembler is different? wrote:
3. Same Source, Same Output

The problem with command line switches selecting output option in case of low level assembly is that the given code will anyway most probably assemble and execute correctly only when the same output is selected that programmer had in mind when writing this code ....
Smile



I REALLY BEG TO DISAGREE (was that loud?, sorry.).

See my example in NASM and you'll agree with me:
====================================
Code:
; test.asm
           [section .code]
           [global main]
main:
           push msg
           [extern puts]
           call puts
           push 0
           [extern exit]
           call exit


           [section .const]
msg db "I am a portable program.",13,10,0
    

====================================

to compile it for Windows i'll do:
nasm -f win32 test.asm

tp compile it for Linux i'll do:
nasm -f elf test.asm

So, wouldn't command line option for format be a better idea ?
Post 14 Oct 2006, 09:43
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
You depend on the external standard library here. If you're going to use some standard library, you may as well provide some standard macros (see vid's FASMLIB project), see also http://board.flatassembler.net/topic.php?t=5131

PS. And see source of fasm itself for a much more sophisticated example of how to assemble the same source for different OSes.
Post 14 Oct 2006, 09:53
View user's profile Send private message Visit poster's website Reply with quote
f14t



Joined: 27 Sep 2006
Posts: 36
f14t
Tomasz Grysztar wrote:
You depend on the external standard
....
PS. And see source of fasm itself for a much more sophisticated example of how to assemble the same source for different OSes.


BUT

just a single command line switch would have been a lot better.

Anyways, tell me what does "PS" mean.
Post 15 Oct 2006, 09:38
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Quote:

Anyways, tell me what does "PS" mean

http://silmaril.ie/cgi-bin/uncgi/acronyms
Post Scriptum [Latin: after writing [used for additional notes at the end of a letter]]
Smile
Post 15 Oct 2006, 10:38
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
just a single command line switch would have been a lot better.
it is NOT possible with just a single command line switch, without some portable library
Post 15 Oct 2006, 11:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
The best thing about FASM is that you control everything from the source code.
You don't need external libraries, don't need long command lines to compile and don't even need a linker.
Also, the code get assembled in the same way it's typed in the source, so you have an exact view of what your executable will look like.
If this feature is dropped than it would not be FASM anymore, and we would just be stopping the evolution! Very Happy
Post 15 Oct 2006, 18:50
View user's profile Send private message Reply with quote
f14t



Joined: 27 Sep 2006
Posts: 36
f14t
OzzY wrote:
The best thing about FASM is that you control everything from the source code.


I agree with that Smile

Quote:
You don't need external libraries,


I do not agree with that Sad

How will i write OpenGl like 3D programs without OpenGL (external you see) ?

How will i write GUI programs like GTK etc without using GTK (external you
got it) ?

Rolling Eyes How do you Do all these things without all these libraries (external you now know it really well) ?

Exclamation
Post 16 Oct 2006, 09:59
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.