Installation (gcc and as)

Running gcc

Debugging your programs gdb

C programs example

Running as

Inlining assembly in C

Handy unix commands

 

Installation (gcc and as)

Windows

For windows I suggest you guys should install cygwin, follow the following steps to install cygwin on your desktops :

  1. Go to http://www.cygwin.com/
  2. Click install cygwin now on the upper right of the page
  3. This launches setup.exe ; click next

                 

 

 

4. Choose install from internet

                 

 

5.        The default settings are good

                  

 

 

6. This is where installation files would be downloaded.

                  

 

7.    Again the default setting is good

 

                  

 

 

8. Please choose http://sigunix.cwru.edu, I testesd this repository and it work

                  

    

 

9.  Please select Devel and Editors from default to install by clicking on the cyclic arrors. The as is selected by deafult , the adventurous ones might select, as many packages as takes to satiate their spirit. Selecting All to be install, would install everything and take about 40-50 mins, and I would strongly encourage that.  

 

                    

 

10.     The files will be downloaded and set up and when 100% is downloaded and set up, click next.        

                     

 

11.  After some very long waiting time, you can click next and see the following screen, select both check boxes and click finish.

                     

 

12. Double click the cygwin icon, and you can start using as and gcc.

 

Refer for further information to these :

     http://cygwin.com/cygwin-ug-net/ov-ex-win.html and

     http://cygwin.com/cygwin-ug-net/setup-net.html#INTERNET-SETUP for further information

 

Unix

On Linux/Solaris/HP-UX etc. usually binutils (containing as) and gcc packages are installed by default. So you can entirly skip this step. If typing "which gcc" and "which as" gives an output specifying the location of the file, you are good. Otherwise contact your administrator.

 

Running gcc

 

        gcc -c file.c  produces only the assembled code file.s, this can be taken by the as and turned into what is called the object code file.o.  You can directly produce the object my calling gcc -S file.c  All such object that you produce for your sources are taken and linked by linking editor ld to create the executable (which you get single-shot when you type gcc file.c

         gcc -Wall file.c   Wall option specifies that you want all warning messages to be reported to you

 

                    gcc file.c -I/usr/home/nishith/math.h, to let file.c find the <math.h>, that it includes by calling #include <math.h>

                   You can above or have the math.h in the same directory as file.c and include like #include "math.h"

 

        Eg.  gcc file.c -lm linking math library, when you use #include <math.h>

 

Do man gcc to get further options information.

http://galton.uchicago.edu/~gosset/Compdocs/gcc.html

 

Debugging your programs 

gdb is the GNU debugger. A debugger is a program that runs other programs, allowing the user to exercise control over these programs, and to examine variables when problems arise.

http://www.cs.princeton.edu/~benjasik/gdb/gdbtut.html is an excellent introduction to gdb 

http://www.delorie.com/gnu/docs/gdb/gdb_toc.html is more comprehensive.

 

 

C programs example

The C tutorial on the class website is an excellent introduction to programming in C

http://www.cs.nyu.edu/courses/fall04/V22.0201-003/c_tutorial/index.html

 

 

Running as

http://linuxselfhelp.com/HOWTO/Assembly-HOWTO/gas.html

 

 

Inlining assembly in C

http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html

http://www-106.ibm.com/developerworks/linux/library/l-ia.html

http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

 

Handy Unix commands