Professional Documents
Culture Documents
Compiling and Running A Program: Introduction To A Programming Language
Compiling and Running A Program: Introduction To A Programming Language
Compiling and Running A Program: Introduction To A Programming Language
By the end of this learning guide module, the students should be able
to:
1. Understand the mechanism on how computer programs are being
compiled;
2. Build source codes designed for programming;
3. Compile and execute a C++ program.
Review
We have learned from the last module the basic components of a
computer program.
Here is an example of assembly language. The below code signals to a processor in binary
code to add the numbers 3 and 4:
1: MOV eax, 3
MOV ebx, 4
ADD eax, ebx, ecx
MACHINE LANGUAGE
Sometimes referred to as machine code or object code, machine
language is a collection of binary digits or bits that the computer reads
and interprets. Machine language is the only language a computer is
capable of understanding.
The exact machine language for a program or action can differ by
operating system. The specific operating system dictates how a compiler
writes a program or action into machine language.
COMPUTER HARDWARE
As a programmer, you must learn, understand, and master the rules of the
programming language to create source programs.
Step 2
The program will then look for the #include statement or what we
call the preprocessor directive.
The compiler checks the source program for syntax errors and, if no error is found,
translates the program into the equivalent machine language of a high-level
language – object program.
Step 4
Programs written on a high-level language are developed in the integrated development
environment (IDE). The IDE contains necessary code(program) such as displaying results and
multiple mathematical functions that programmers can use, rather than making their own code.
Once the program is developed and successfully compiled, you must still bring the code for the
resources used from the IDE into your program to produce a final program that the computer
can execute.
This prewritten code (program) resides in a place called the library. A program called a linker
combines the object program with other programs in the library and is used in the program to
create the executable code.
Step 5
The program is loaded to the main memory for execution. The loader will be
responsible for doing this task.
Step 6
Finally, the program is executed.
What you have learned today is how to run and compile a computer
program.
We create our source codes using a workspace in the Ide or a text editor.
The preprocessor directive will include all the necessary library in the
program.
The compiler checks the source program for syntax errors and, if no error
is found, translates the program into an object program.
The linker combines the object program with other programs in the
library and is used in the program to create the executable code.
Once it becomes an executable code, it can be run.
We have also discussed o how to create and run a program using the IDE –
DevC++/Codeblocks. We have discussed how to create a program and all the
necessary steps to run the program.