Getting Started with gcc, the GNU C compiler

For the EE460N lab assignments, you need to make sure that all your code successfully compiles with the gcc compiler. gcc is an ANSI-C compiler (and linker) that is available free on the UNIX environment. Let's say, for lab assignment 1, you named the file that contains your assembler program assembler.c. To compile this file and produce an executable you need to type the following in the UNIX shell:

gcc -ansi assembler.c

If your program does not have any errors, you will notice that the above command produces an executable file named a.out. This is the standard name for the executable created by gcc unless you provide your own preferred name. Now, all you need to do to run your assembler is to type:

a.out <inputfile> <outputfilename>

where inputfile is the name of the file that contains a program written in LC-3b assembly language, and outputfilename is the name of the file that will contain the output of your assembler. If the above doesn't run your program try running it by typing:

./a.out <inputfile> <outputfilename>

If you would like to call your executable with a different name, you need to use the -o option of gcc. For example, if you want your executable named assemble, you need to compile the source code for your assembler (assembler.c) with the following command:

gcc -ansi -o assemble assembler.c  

If you decide to use any of the math functions in math.h, you also have to link the math library by using the command:

gcc -lm -ansi -o assemble assembler.c

To run your assembler now, just use the following command:

./assemble <inputfile> <outputfilename>
If you would like to learn more about gcc, try the following on the UNIX command prompt:
man gcc