Executable Programs

You may already know that the computer itself only understands natively, commands in one specific language, called machine code or machine language. Machine code itself is just a pile of 1's and 0's, so not readily understood by human beings, however there is a way to indirectly write this language. It is called Assembly Language. By making use of a program called an assembler, you can basically write machine code without the 1's and 0's. Instead, for each command the machine understands, an assembler allows-na you to write a short mnemonic code which stand for the particular combination of 1's and 0's which specifies that instruction. These mnemonic codes, when you look at them, give some sort of hint as to what the individual instructions do, e.g: ADD AX,BX, whose meaning you can probably guess.

If you are interested in assembly language, please see our online assembly language tutorial, which you can find a link to on the left hand side of the page. Assembly language programs are essentially the most efficient kind, since they allow total control over the machine. However, for most programming tasks, writing in assembly language takes a long time and is not very natural (the machine only understands very simple instructions, and anything complicated that you want to do, you have to build up out of hundreds or thousands of these more basic instructions). Now this is where a C compiler comes in. It allows-na you to write an executable program (machine code program) much more easily.


The Compiler

A C compiler is a program which converts much more natural and complex instructions (this time written in the C language) into a series of assembly language or even machine code instructions which the computer can then execute.

The whole process can involve two or three steps:

Firstly, you write your program down in the C language. Usually you do this in some kind of text editor. Actually, even MS Notepad will do for this, however there are much more sophisticated editors available which are designed to help you write the program. These are usually called IDE's, or Integrated Development Environments. They consist of some kind of glorified text editor and perhaps some extra tools for various other tasks which you might need to undertake to produce a decent C program.

The second step is to compile your C program using a C compiler. Sometimes IDE's have a compiler built in, or attached to them in some way, so that compiling your program is just a matter of pressing the appropriate button. Once it is compiled, you end up with a file which can be run on your computer like any other program that you have. This executable file is the end product, an application, written by you, which you can actually run!

If things have gone well, compiling (and running) your program, may be the final step. However, as you will soon find out, this is rarely the last step. Usually your program will have some kind of error in it, and you will have to undertake a third step, called debugging. Put simply, this is the process of finding the error in your written program, and there are tools available for this too, called debuggers.

Sometimes there is an additional step involved along the way, which I have not mentioned. You will notice above that I said a C compiler could produce either machine code or assembly language. If it produces the former, then the computer can execute this directly. However, if only assembly language is output by your compiler, then you have to use an assembler to turn the assembly language into an executable file. Fortunately, few compilers produce only assembly language and most go directly to machine code so that you can just run the final product directly.