programming languages compiler
TRANSCRIPT
-
7/28/2019 Programming Languages Compiler
1/15
Overview of Programming Languages
-
7/28/2019 Programming Languages Compiler
2/15
COMPUTER LANGUAGE A language is a system of communication.
A computer language is a means of communication usedto communicate between the people and the computer.
Computer programmer uses the computer language to
tell the computer what to do.
-
7/28/2019 Programming Languages Compiler
3/15
BROAD CATEGORIES OF COMPUTER LANGUAGES
There are three categories of programming languages:
Machine language: language of 0 and 1 Assembly language: language of mnemonics High-Level language: language of English wordsand mathematical symbols.
Machine languages and assembly languages are alsocalled low-level languages
-
7/28/2019 Programming Languages Compiler
4/15
P ROGRAMMING LANGUAGES Machine Language
Natural language of a particular computer.
Consists of strings of numbers(1s, 0s)
Instruct computer to perform elementaryoperations one at a time.
Machine dependant.
-
7/28/2019 Programming Languages Compiler
5/15
Machine Language
Advantages : Fast and efficientMachine orientedNo translation required
Disadvantages :
Not portable Not programmer friendly
-
7/28/2019 Programming Languages Compiler
6/15
PROGRAMMING LANGUAGES
Assembly Language
Assembly language programs use mnemonics torepresent machine instructions.
Translators programs called Assemblers to convertassembly language programs to machine language.
E.g. add overtime to base pay and store result in gross pay
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
-
7/28/2019 Programming Languages Compiler
7/15
MACHINE LANGUAGE AND ASSEMBLY LANGUAGE
Compare the following codes :
Assembly code:MOV AX , var1
ADD AX , var2MOV var1 , AX
Machine Code:
1010 0001 0000 0000 0000 00000000 0011 0000 0110 0000 0000 0000 00101010 0011 0000 0000 0000 0000
Which one is easy to understand/remember?
-
7/28/2019 Programming Languages Compiler
8/15
PROGRAMMING LANGUAGES
High-level languages
To speed up programming even further.Single statements for accomplishingsubstantial tasks.Translator programs called Compilers toconvert high-level programs into machine
language.E.g. add overtime to base pay and store resultin gross pay
grossPay = basePay + overtimePay
-
7/28/2019 Programming Languages Compiler
9/15
HIGH -LEVEL LANGUAGES
Advantages : Portable or machine independentProgrammer-friendly
Disadvantages :
Not as efficient as low-level languages
Need to be translated
Examples : C, C++, Java, FORTRAN, Visual
Basic
-
7/28/2019 Programming Languages Compiler
10/15
COMPILER
A compiler is a computer program thattransforms human readable source code of another computer program into the machine
readable code that a CPU can execute.
The act of transforming source code intomachine code is called "compilation".
Compiler converts all the files of a given projectat once.
-
7/28/2019 Programming Languages Compiler
11/15
INTERPRETER
This is a software tool which interprets the user written code line by line, unlike compiler, which
processes everything at once.
In this case a single line is executed at a time. Itis time consuming and not used in real-timeapplications.
-
7/28/2019 Programming Languages Compiler
12/15
LINKER
Linker uses the object files created by thecompiler and then uses the predefined libraryobjects to create an executable.
This executable is the one which is seen by thecommon user .
-
7/28/2019 Programming Languages Compiler
13/15
ASSEMBLER
While compiler processes high level languages,assembler has the capability of processing onlythe low level assembly language.
This assembly language is extremely core(microprocessor/platform) specific.
-
7/28/2019 Programming Languages Compiler
14/15
COMPILATION /L INKING A C program consists of source code in one or more filesEach source file is run through the preprocessor and compiler ,resulting in a file containing object codeObject files are tied together by the linker to form a single
executable program
Preprocessor/Compiler
Executable codea.out
Source codefile1.c
Object codefile1.o
Source codefile2.c Preprocessor/Compiler Object codefile2.o
Linker Libraries
-
7/28/2019 Programming Languages Compiler
15/15
HOW TO COMPILE To compile and link a C program that is contained entirely in onesource file:cc program.c
The executable program is called a.out by default.If you dont like this name, choose another using the o option:
cc program.c o newname
To compile and link several C source files:cc main.c extra.c more.c
This will produce object (.o) files, that you can use in a later
compilation:cc main.o extra.o more.cHere, only more.c will be compiled the main.o and extra.o files willbe used for linking.
To produce object files, without linking, use -c:cc c main.c extra.c more.c