NOTE: This how-to was tested in Ubuntu 14.04 LTS. Other Linux distribution may employ other means, but the basic principle should be the same. So read on and make the necessary adjustment as you see fit.
- Download fasm for Linux.
- Open a terminal and switch user to root:
$ sudo su
when ask for a password, type in your password (normally, the one you used when you login to your system)
- Copy fasm-1.71.22.tgz into /opt directory (or to a directory where you want fasm to finally reside. I chose it to reside to /opt)
# cp /<source_dir>/fasm-1.71.22.tgz /opt
- Extract fasm
# tar -xzvf fasm-1.71.22.tgz
fasm directory will be created containing the following:
the compiler is already in binary form (although you have to option to rebuilt it from the included source code if you are more adventurous), so you can actually use it right away.
- Go into fasm directory and execute fasm to see if it will run
# cd /opt/fasm
you should see something like below:
- Now, include fasm directory into your path so you can execute it anywhere from your CLI (Command Line Interface). We want it to be available system-wide. Open a terminal and change user to root:
$ sudo su
# echo “export PATH=$PATH:/opt/fasm” >> /etc/profile
Edit /etc/environment file and insert the path to fasm in the PATH environment variable:
After any of these changes, you need to reboot your computer for it to take effect.
If everything works fine, you should be able to see the following when you execute fasm anywhere in your CLI:
- To fully test if we really have a working fasm, let’s compile the included hello.asm. Open a terminal and copy the hello example files from /opt/fasm/examples/elfexe/:$ cd ~
$ mkdir asm
$ cd asm
$ cp /opt/fasm/examples/elfexe/hello.asm .
$ cp /opt/fasm/examples/elfexe/hello64.asm . ## you can also include this if you have 64-bit computer
Compile to create their corresponding executable files:
$ fasm hello.asm
$ fasm hello64.asm
The following should be the output: