1.5 COMPUTER LANGUAGES
Fig
32:
Translation by Assembler
Fig
33:
Translation by Compiler / Interpreter
Programming Language
Def:
A set of instructions given to the
computer to execute a particular task is called a program and the language in
which we write a program is called the programming language.
Computer
programming languages are classified into three categories:
Ø High-level
Language
Ø Middle-level
Language
Ø Low-level
Language
Fig 31: Computer Programming
Languages
1.
Low-level
Language
·
Low-level
language is easily understood by computers.
·
They
are machine dependent.
·
Programmes
written in these languages are not transferable from one computer to another.
a.
Machine Language
· It belongs to
first generation of computer languages.
· The vocabulary
of this language consists of two binary numbers 0’s and 1’s where 0 indicates
low voltage and 1 indicates high voltage.
· Each instruction
has a specific format, consisting of two fields. The first field is opcode and
the second field is address.
OPCODE
|
ADDRESS
|
where
OPCODE
à Stands for
operation code. It indicates what operation is to be done, like addition,
subtraction, load, store, etc.
ADDRESS
à Memory location
where data is referenced.
Advantages
i.
Can
be directly typed and executed
ii.
No
translator program is required.
Disadvantages
i.
Difficult
to remember machine instructions.
ii.
Difficult
to understand, modify and debug
iii.
Difficult
to remember addresses of data and instructions.
iv.
Each
and every information is numerical in nature.
Program
to add two numbers in machine language
PROGRAM
|
EXPLANATION
|
0011
1100
|
Load
A register with value 7
|
0000
0111
|
|
0000
0110
|
Load
B register with 10
|
0000
1010
|
|
1000
0000
|
A
ß A + B
|
0011
1010
|
Store
the result into the memory location whose address is 100
|
0110
0110
|
|
0111
0110
|
Halt
processing
|
b.
Assembly Language
· It belongs to
second generation of computer languages.
· In this language
we make use of symbolic words referred as mnemonics.
· The program
which translates assembly language program into machine language program is
called assembler.
Advantages
i.
Easy
to remember operation codes.
ii.
Easy
to understand the program.
iii.
Easy
to write program, modify and debug.
iv.
Need
not remember addresses of operands and instructions locations.
Disadvantages
i.
The
mnemonics are machine dependent. They differ from one computer to another.
ii.
There
is no standardization.
iii.
It
has less efficient than machine language.
Program
to add two numbers in assembly language
PROGRAM
|
EXPLANATION
|
LD
A, 7
|
Load
A register with value 7
|
LD
B, 10
|
Load
B register with 10
|
ADD
A, B
|
A
ß A + B
|
LD
(100), A
|
Store
the result into the memory location whose address is 100
|
HALT
|
Halt
processing
|
2.
Middle-level
Language
·
The
“C” language is called middle-level language because it has the features of
both high-level language and low-level language.
3.
High-level
Language
·
High-level
language is easily understood by the user.
·
These
languages are more concerned with the problem specification and not oriented
towards the details of a hardware.
·
HLL
are English-like statements.
·
The
elements of these languages are alphabets, digits, punctuations and other
special symbols.
·
Program
written for one computer can be run on another computer with very little or no
modification.
·
In
high-level languages, we have two types of translators – compiler and
interpreter.
Difference
between Compiler and Interpreter
S.NO.
|
COMPILER
|
INTERPRETER
|
1.
|
Scans
the entire program before translating it into machine code.
|
Translates
and executes the program line by line.
|
2.
|
Converts
the entire program to machine code and only when all the syntax errors are
removed, does execution takes place.
|
Each
time the program is executed, every line is checked for syntax error and then
converted to the equivalent machine code.
|
3.
|
Slow
in debugging.
|
Good
for debugging.
|
4.
|
Execution
time is less.
|
Execution
time is more.
|
5.
|
Memory
requirement is more.
|
Memory
requirement is less.
|
Ex:
|
C,
C++, JAVA
|
BASIC,
JAVA, LISP
|
Advantages
i.
Easy
to understand.
ii.
Easy
to write, modify and debug.
iii.
Standardized.
iv.
Portability.
Disadvantages
i.
Less
efficient than low-level language.
ii.
Poor
control on hardware.
a.
Procedural Language
·
Procedural
language is a type of computer programming language that specifies a series of
well-structured steps and procedures within its programming context to compose
a program. It contains a systematic order of statements, functions and commands
to complete a computational task or program.
·
Procedural
language segregates a program within variables, functions, statements and
conditional operators. Procedures or functions are implemented on the data and
variables to perform a task. These procedures can be called/invoked anywhere
between the program hierarchy, and by other procedures as well.
·
Example: C++, JAVA, PASCAL, FORTRAN
b.
Non-procedural
Language
· A
computer language that does not require writing traditional programming logic.
Also known as a "declarative language," users concentrate on defining
the input and output rather than the program steps required in a procedural
programming language.
· Example: Prolog,
LISP
c.
Problem-oriented
Language
· Problem-oriented
Languages were designed to solve specific problems e.g. querying databases and
allowed the programmer to concentrate more on the problem rather than spending
time learning the complex syntax of the language.
· Example: MATLAB
Difference
between Machine Language and High-level Language
S.NO.
|
MACHINE
LANGUAGE
|
HIGH-LEVEL
LANGUAGE
|
1.
|
Uses
only two symbols 0’s and 1’s.
|
Uses
alphabets, digits and special symbols.
|
2.
|
Each
instruction is a sequence of 0’s and 1’s.
|
Each
instruction is like English statement.
|
3.
|
Can
be directly executed.
|
Cannot
be directly executed.
|
4.
|
Machine
dependent.
|
Machine
independent.
|
5.
|
Difficult
to understand, modify and debug.
|
Easy
to understand, modify and debug.
|
6.
|
Efficient
(fast)
|
Less
efficient (slow)
|
7.
|
No
standardization followed.
|
Standardization.
|
Difference
between Assembly Language and High-level Language
S.NO.
|
ASSEMBLY
LANGUAGE
|
HIGH-LEVEL
LANGUAGE
|
1.
|
Mnemonic
instructions.
|
English-like
instructions.
|
2.
|
Machine
dependent.
|
Machine
independent.
|
3.
|
Assembler
is used in translation process.
|
Compiler
or interpreter is used in translation process.
|
4.
|
Difficult
to understand, modify and debug.
|
Easy
to understand, modify and debug.
|
Concept of
Linker and Loader
Linker
In high level languages, some
built in header files or libraries are stored. These libraries are predefined
and these contain basic functions which are essential for executing the
program. These functions are linked to the libraries by a program called
Linker. If linker does not find a library of a function then it informs to
compiler and then compiler generates an error. The compiler automatically
invokes the linker as the last step in compiling a program.
Not only built
in libraries, it also links the user defined functions to the user defined
libraries. Usually a longer program is divided into smaller subprograms called
modules. And these modules must be combined to execute the program. The process
of combining the modules is done by the linker.
Loader:
Loader is a program that loads
machine codes of a program into the system memory.
In Computing, a loader is the part of an Operating
System that is responsible for loading programs. It is one of the
essential stages in the process of starting a program. Because it places
programs into memory and prepares them for execution. Loading a program involves
reading the contents of executable file into memory. Once loading is
complete, the operating system starts the program by passing control to the
loaded program code. All operating systems that support program loading have
loaders. In many operating systems the loader is permanently resident in
memory.
Translation Hierarchy
Translation Hierarchy
Fig 34: Translation Hierarchy
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.