flat assembler
Message board for the users of flat assembler.

Index > Windows > MASM vs FASM vs Linus for learning

Author
Thread Post new topic Reply to topic
cj011



Joined: 06 Feb 2008
Posts: 1
cj011 06 Feb 2008, 07:44
I have been reading up on the Intel assembly code for sometime. The books I have are directed towards MASM, Linux, and now I have stumbled upon FASM. What would be the benefit of learning on FASM rather than the other options? My goal is to learn in assembly for the Intel processor. I really don't care what I use, just to get it done.

thanks everyone,

Chris
Post 06 Feb 2008, 07:44
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13190
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 06 Feb 2008, 13:22
benefits = a lot
i like the following style

mov eax, address ; address for that variable
mov eax, [address] ; value on that address
Post 06 Feb 2008, 13:22
View user's profile Send private message Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 533
drhowarddrfine 06 Feb 2008, 13:40
For one, MASM only runs on Windows so FASM has an advantage in that alone.
Post 06 Feb 2008, 13:40
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 06 Feb 2008, 14:55
FASM is more low-level than MASM and doesn't have any linkers and all that other BS

The benefit is that it's a Flat Assembler
Post 06 Feb 2008, 14:55
View user's profile Send private message Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap 06 Feb 2008, 15:35
There is little difference between the basic syntax of these assemblers, which is what you will learn first (you won't need more advanced things like macros).
With MASM you will address global variables like that :
Code:
mov eax, var    

And with FASM :
Code:
mov eax, [var]    


The assemblers also provide short mnemonics for the FPU which are different. To me these are the main differences a beginner would encounter.
You will also learn more about executable files structure when building them with FASM, but it's also more difficult to understand at the begining (you have to create yourself the sections, including the imports one). I would sugget you to first take a look at MASM since its syntax is still the most used nowadays (it is recognized by MSVC++, ICC, GCC and other tools, for example IDA).
Post 06 Feb 2008, 15:35
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 06 Feb 2008, 15:42
Quote:

(you have to create yourself the sections, including the imports one).

Quickly solvable by "include 'win32ax.inc'", then you use .code, .data, .ends entrypoint, like MASM.
Post 06 Feb 2008, 15:42
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 08 Feb 2008, 01:28
Unless you're using MASM code in your projects, I'd suggest not to use it. FASM can do pretty much anything you need. See the following links for more details.

Why do you like FASM?
http://en.wikipedia.org/wiki/FASM
Post 08 Feb 2008, 01:28
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 08 Feb 2008, 02:03
big benefit of NASM/FASM/YASM is it's synax, which is quite more logical than MASM/TASM syntax, and much nicer than gas (GNU assembler) syntax.

FASM compared to NASM/YASM:
- basic assembly code is pretty much the same
+ FASM can output executable directly (not THAT important but may help if you can't use linker yet)
+ FASM has more powerful macrosyntax than NASM/YASM
- FASM is written in FASM (self-compiling), so there is no native 64bit version of FASM, and it's seldom included in application package of linux distros. no "apt-get" or "emerge"
Post 08 Feb 2008, 02:03
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 08 Feb 2008, 02:23
FASM has official syntax-highlighting IDEs w/ itself built-in as well as being faster and smaller than NASM. But NASM supports more object and debug formats (but see OBJCONV) and listing (officially ... at least 1.67.23 supported a hack for that). I think you now need a C99 compiler (e.g. GCC) to make NASM, too (although they do have hacks for OpenWatcom). Oh, and personally, I like FASM only reporting one error at a time (instead of a billion).

GAS supports Intel-style now, but it's one-pass only (I think), so encodings are bigger. Plus, it's kinda goofy. But some people prefer it (e.g. UPX), probably because it's ubiquitous.
Post 08 Feb 2008, 02:23
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 533
drhowarddrfine 08 Feb 2008, 03:30
Quote:

much nicer than gas (GNU assembler) syntax.

I have no problems with it and use it all the time. It's called ATT syntax, btw.
Quote:

GAS supports Intel-style now, but it's one-pass only (I think), so encodings are bigger.

It's not just one pass so I don't know why encodings would be bigger.
Quote:

Plus, it's kinda goofy. But some people prefer it (e.g. UPX)

I think I prefer it, too, but, in any case, I have no problem with it.
Post 08 Feb 2008, 03:30
View user's profile Send private message Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap 08 Feb 2008, 20:02
LocoDelAssembly wrote:
Quickly solvable by "include 'win32ax.inc'", then you use .code, .data, .ends entrypoint, like MASM.

Thanks I didn't know that. BTW .data? and .const are also commonly used with MASM.

rugxulo wrote:
I think you now need a C99 compiler (e.g. GCC) to make NASM, too (although they do have hacks for OpenWatcom).

Note that GCC isn't a C99 compiler yet.

_________________
(French only) http://dap.developpez.com
Post 08 Feb 2008, 20:02
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Feb 2008, 21:50
Well, for .const you can use this macro

Code:
macro .const
{
  section '.const' data readable
}    


As for .data? well that one would be harder but I suggest you using regular .data and make sure that any data definition you do is "?" or any other kind of definition that doesn't defines at any constant. If you have both, initialized and uninitialized data then use a single .data for both but place the initialized data first and the uninitialized data last so the virtual size will be the size of both kind of data but the file size will be only the size of the initialized data.

Try to use less sections as possible, only use a different one if you need diferent types of properties (check them at http://flatassembler.net/docs.php?article=manual#2.4.2). Note that actually you can have only one section and use it for all, but since that would make all bytes readable, executable and writable perhaps you will like to use separated sections (and maybe some anti-virus will mark you executable as virus for being so unconventional for having one section).

I hope I have not confused you much Razz
Post 08 Feb 2008, 21:50
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 13 Feb 2008, 04:18
dap wrote:
rugxulo wrote:
I think you now need a C99 compiler (e.g. GCC) to make NASM, too (although they do have hacks for OpenWatcom).

Note that GCC isn't a C99 compiler yet.


No, it's not complete yet, but what parts it does have implemented are now (mostly?) required to build the latest NASM.
Post 13 Feb 2008, 04:18
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:  


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

Website powered by rwasa.