Programming with FASM – first steps .

By | 30/04/2012

The FASM is a self-assembling open-source 80×86 assembler for

DOS, Windows and Linux. It supports all 8086-80486/Pentium instructions

with MMX, SSE, SSE2 and with more features.

FASM contains many programming options and features.

The source code can be written in different ways because of control

directives, macros and management of resources.

FASM, by default uses the Intel syntax for the assembly


You can go on and download it.

Below we see the files that are used by fasm.

The FASMW is a GUI to help in programming, as shown here.

fasmw GUI

Let’s see some example and how this working…

In this first example you will see a message box.

See result in image show below:

fasm message box

First line include some macro – functions.

If the source code is another folder, like for example in a folder

named asm in same folder with INCLUDE, then you need to declare this

macros in this way:

As you see the fasm is not case sensitive , in this case.

The next two lines are data declarations.

Code execution takes place between the two labels:

Code between these labels is written in assembler and can be easy


If you think it is easy then let’s see a second example, here’s the

source code:

It seemed more complicated and structured differently from the first


Let’s see the result.

fasm another example

As I said above, fasm – The flat assembler is a series of directives

and special words.

That help us if we know, if not then we use what we know.

Let’s look the source code of the second example and try to understand

it a bit.

Tihis tell us about creating PE file for the x86-64 architecture or if

you want use PE64 keyword instead of PE in the format declaration

This select the Portable Executable output format and will be a console


Also can be console or GUI for Windows applications,

native for Windows drivers, EFI, EFIboot or

EFIruntime for the UEFI or optional DLL and


Next entry directive sets the entry point for MZ executable.

The section directive defines a new section and it should be

followed by flags.

We have three sections in this instance one for data, one for code and

one for other data

Other source code lines are easily recognized by how they were reported

in these sections.

I hope you enjoyed the tutorial, I will expect you to come and other


Use the contact page to write

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.