Mod 4 - Computer Languages
Mod 4 - Computer Languages
Literacy / Fundamentals of
Information Technology
MOD 4 - COMPUTER
LANGUAGES
Learning Objectives
• Introduction to Computer Languages
• Generations of Programming languages
Introduction to Computer Languages
• A programming language allows a programmer to develop the sets of
instructions that constitute a computer program.
• Many different programming languages have been developed, each
with its own unique vocabulary; grammar, and use.
• A programming language is any set of rules that converts strings,
or graphical program elements in the case of visual programming
languages, to various kinds of machine code output.
• Programming languages are one kind of computer language, and are
used in computer programming to implement algorithms.
• Most programming languages consist of instructions for computers.
• There are programmable machines that use a set of specific instructions,
rather than general programming languages.
• Since the early 1800s, programs have been used to direct the behavior of
machines such as Jacquard looms, music boxes and player pianos.
• Thousands of different programming languages have been created, and
more are being created every year.
• Many programming languages are written in an imperative form (i.e., as a
sequence of operations to perform) while other languages use
the declarative form (i.e. the desired result is specified, not how to achieve
it).
Generations of Programming languages
• There are five generations of programming languges:
i. First Generation Languages: These are low-level languages like
machine language.
ii. Second Generation Languages: These are low-level assembly
languages used in kernels and hardware drives.
iii. Third Generation Languages
iv. Fourth Generation Languages
v. Fifth Generation Languages
1. First Generation - Machine Language
• The computers can execute a program written using binary digits only.
• This type of programs is called machine language programs and the
programming language is called machine code.
• Since these programs use only '0's and '1's it will be very difficult for
developing programs for complex problem solving.
• Also it will be very difficult for a person to understand a machine language
program written by another person.
• At present, computer users do not write programs using machine language.
• Also these programs written for execution in one computer cannot be used
on another type of computer. i.e., the programs were machine dependent.
2. Second generation - Assembly Language
• In assembly language mnemonic codes are used to develop program
for problem solving.
• The program given below shows assembly language program to add
two numbers A & B.
• Program Code Description
i. READ A It reads the value of A
ii. ADD B The value of B is added with
A
iii. STORE C The result is stored in C
iv. PRINT C The result in ‘C’ is printed
v. HALT Stop Execution
• Assembly language is designed mainly to replace each machine code
with and understandable mnemonic code.
• To execute an assembly language program it should first be translates
into an equivalent machine language program.
• Writing and understanding programs in assembly language is easier
than that of machine language.
• The programs written in assembly language are also machine
dependent.
• Assembly language is translated into machine code using an
assembler before they can be executed.
What is Assembly Language?
• Each personal computer has a microprocessor that manages the
computer's arithmetical, logical and control activities.
• Each family of processors has its own set of instructions for handling
various operations like getting input from keyboard, displaying
information on screen and performing various other jobs.
• These set of instructions are called 'machine language instruction'.
• Processor understands only machine language instructions which are
strings of 1s and 0s.
• However machine language is too obscure and complex for using in
software development.
• So the low level assembly language is designed for a specific family of
processors that represents various instructions in symbolic code and a
more understandable form.
Advantages of Assembly Language
i. An understanding of assembly language provides knowledge of:
ii. Interface of programs with OS, processor and BIOS;
iii. Representation of data in memory and other external devices;
iv. How processor accesses and executes instruction;
v. How instructions accesses and process data;
vi. How a program access external devices.
Other advantages of using assembly language are:
i. It requires less memory and execution time;
ii. It allows hardware-specific complex jobs in an easier way;
iii. It is suitable for time-critical jobs;
Example of Assembly
• Source code format
• A typical line in assembly language programme might be as follows:
• LOOP: MOV.B r0, #80 ;initialise counter
• This line will be assembled into a single instruction (in this case 11 0000
1000 0000 in binary, or 3080); the assembly language and the machine code
correspond to each other.
• It has four parts;
i. label,
ii. mnemonic,
iii. operand,
iv. comment;
• Not all are present in every line.
1st Part
• The first part (LOOP in this example) is a label ; this is a word, invented by the
programmer, which identifies this point in the program.
• It will be set equal to the value of the address where this instruction is
stored.
• So, for example, if later in the programme there is a statement JMP LOOP, the
assembler programme will replace the label LOOP with the actual value of
LOOP, which is the address at which this instruction is stored.
• (For the assembler to recognise this as a label, the label must begin at the
first character in the line., in some assemblers a colon ":" follows the label) So
if the address at which the instruction is stored is 4F, LOOP takes on the value
4F.
• If LOOP is used later in the programme, the assembler will give it the value
4F.
2nd Part
• The second part is the mnemonic.
• This corresponds to a particular kind of instruction (opcode sent by
the Dispatch Unit).
• The intention is that the word chosen (by the manufacturers) for the
mnemonic is easy to remember, and indicates what the instruction does.
• In this case, the instruction moves a literal value (one byte) into the
register 0, hence MOV.B r0,#80
3rd Part
• The third part of the line is an operand (there may be two); in this
case the operand is the value 80 (in Hex) and the register r0.
4th Part
• The last part of the line is a comment.
• This does not affect the actual instruction at all;
i. it is not part of the instruction, and
ii. is not assembled;
iii. instead it helps the programmer to remember what this part of the
program does.
• The comment is preceded by a semi-colon.
3. Third Generation - High Level
Languages
• In the 1950’s computer manufacturers and user groups started to develop
the high level languages in order to allow application programs, which are
machine independent.
• High level language permits the user to use understandable codes using the
language structure.
• In order to execute a high-level language program, it should be translated
into a machine language either using a compiler or interpreter.
• A third generation (programming) language (3GL) is a grouping of
programming languages that introduced significant enhancements to
second generation languages, primarily intended to make the programming
language more programmer-friendly.
• English words are used to denote variables, programming structures
and commands, and Structured Programming is supported by most
3GLs.