UMBC CMSC 313, Computer Organization & Assembly Language, 
  Spring 2002, Section 0101
NASM on linux.gl.umbc.edu
Setting Up
We are using verion 0.98 of NASM for this course. The CD-ROM included in 
the textbook has version 0.97. It is probably fine to use version 0.97, but 
if you are going to install the software on your machine you might as well 
install the latest version. A copy of the source code for 0.98 is available 
locally at:
   /afs/umbc.edu/users/c/h/chang/pub/cs313/nasm-0.98.tar.gz
   
or you may obtain it from the  
official NASM web site.
To run NASM, you should place the following alias in the .cshrc 
or .tcshrc in your home directory (or wherever you put your 
aliases):
   alias nasm /afs/umbc.edu/users/c/h/chang/pub/cs313/nasm
After you logout and log back in, you should be able to just type 
nasm to invoke the NASM assembler.
Running NASM
Suppose you have an assembly language program in a file called 
"hello.asm". You can assemble it for Linux with the command:
   nasm -f elf hello.asm
The "-f elf" option tells nasm to output the object code in the Executable 
and Linking Format (ELF) that Linux uses. This creates an object file 
called "hello.o".  The object code is still not executable.  To create
an executable file, we must use the linking loader "ld":
   ld hello.o
This then creates an "a.out" file that you can execute from the Linux 
command line.
If the loader complains that it cannot find the entry symbol _start, it is 
because you do not have a global label _start for the entry point of your 
program. To fix this problem, the beginning of the code section of your
program should look like:
        SECTION .text                   ; Code section.
        global _start
_start:                                 ; Entry point.
Another useful option in nasm is "-l" for specifying a listing file. The 
command:
   nasm -f elf hello.asm -l hello.lst
which will produce a listing file named "hello.lst".  The listing file 
conatins both the source listing of the assembly language program and the 
machine code for each assembly language operation.
The "-g" option for nasm unfortunately does next to nothing. It is supposed 
to generate debugging information placed in the object file for the 
debugger. However, this is still an unimplemented feature in NASM.
For more information on running NASM, consult 
Chapter 2 of the online NASM 
manual, or type
   nasm -help
Last Modified:
22 Jul 2024 11:29:34 EDT
by
Richard Chang
to Spring 2002 CMSC 313 Section Homepage