Greetings EveryOne
This tutorial will show you How to run 16-bits NASM on Linux.
This method is tested on Ubuntu 11.10 and it may or may not work on other Linux distros.
1) First you need to download and install "DosBox", open Terminal (alt+ctr+t) then type:
sudo apt-get install dosbox
2) Next go to this link:
http://www.nasm.us/pub/nasm/releasebuilds/2.09.10/dos/and download nasm-2.09.10-dos.zip (when this tutorial was created the current version of NASM is 2.09.10).
Now extract the zip file to "/home/(username)/Desktop".
You need "Unrar-free" or "Unrar" for the extraction process.
3) After setting up "DosBox" and "nasm", open your terminal or your "Dash home" then type: dosbox and hit enter key, voila now you can see the emulated dos command line.
N.B: for your own convenient you might need to change your keyboard layout on dosbox, do to it simple type:
keyb "layout"
i.e:
keyb fr
4) At this stage you need to mount your hard drive like this:
Z:\>mount c "folder path for the hard drive to be mounted at"
For our tutorial type this:
Z:\>mount c /home/(username)/Desktop/nasm-2.09.10
you going to see this line:
Drive C is mounted as local directory /home/(username)/Desktop/nasm-2.09.10/
next type:
Z:\>c:
Now you can test if "nasm" is functioning, type:
c:\>nasm -h
if you see this: Illegal command: nasm.
it means something is wrong otherwise you will know its working fine.
5) Now we can do some coding, open "gedit" or your favorite editor and copy past this code:
segment .text
global start
start:
mov DL, 'a'
mov AH, 2h
int 21h
mov AX, 4C00h
int 21h
save it as "test.asm" at "/home/(username)/Desktop/nasm-2.09.10".
6) Lets assemble our code, go back to "DosBox", and type this:
c:\>nasm -f bin test.asm -o test.com
if no error message got printed, it means everything went well.
7) Testing our "com" file, goto "/home/(username)/Desktop/nasm-2.09.10" and see if "test.com" was created, if it's there go back to "DosBox" and type:
c:\>test.com
if you see this:
c:\>test.com
a
c:\>
I must say congratulation you got 16-bits NASM code to work on Linux.
Enjoy, Shikatsu.