Friday 6 November 2020

Computer Languages: Machine, Assembly and High Level Language

 

COMPUTER LANGUAGES

A language acceptable to a computer system is called computer language or programming language, and the process of writing instructions in such a language is called programming or coding.

All computer languages can be classified broadly into following three categories:

1.     Machine language

2.     Assembly language

3.     High level language

1.   Machine Language:

o   Although computers can be programmed to understand many different computer languages, every computer understands only one language without using a translation program.

o   This language is called machine language of a computer. It is normally written as strings of binary 1s & 0s.

o   Machine language instruction normally has two part format.  The first part is operation code (opcode) that tells the computer what function to perform, and the second part is operand that tells where to find out stored data to be manipulated.

o   Every computer has a set of operation codes called its instruction set.

o   Typical operations included in the instruction set of a computer are:

o   Arithmetic operations

o   Logical operations

o   Branch operations for transfer of control to the address given in the operand field

o   Data movement operations for moving data between memory locations and the registers

o   Data movement operations for moving data from or to IO devices

o   This language is not easy to use because it is difficult to read and understand and because it is written in a number system which we are not familiar with.

 

Advantage of machine language:

Programs written in machine language can be executed very fast by computer because machine instructions are understood by the computer without the need for any translation.

 

Disadvantages of machine language:

1.    Machine Dependent: As the internal design of every type of computer is different from every other type of computer, machine language also differs from computer to computer.

2.    Difficult to Program: Although a computer executes machine language programs directly and efficiently, it is difficult to program in machine language.  It is necessary for a programmer to either memorize the dozens of operation code numbers for the commands in the machine’s instruction set or refer to a reference card constantly.

3.    Error Prone: For writing programs in machine language, a programmer has to remember the opcodes and must keep track of storage locations of data and instructions. This makes it very difficult for him to concentrate fully on the logic of the problem resulting in programming errors.  Additionally, due to lack of any immediate visual indication of an error as the programmer writes machine language code, it makes removal of such errors more difficult.

4.    Difficult to Modify: It is difficult to correct or modify machine language programs. Checking machine instructions to locate errors is very difficult and time consuming.

 

 

2.   Assembly Language:

o   Programming in machine language is difficult and error prone because a programmer needs to:

1.    Write numeric codes for the instruction in a computers instruction set.

2.    Write the storage locations of data and instructions in numeric form.

3.    Keep track of storage locations of data and instructions while writing a program.

 

o   A language that allows instructions and storage locations to be represented by letters and symbols instead of numbers is called an assembly language or symbolic language.

o   A program written in assembly language is called assembly language program or symbolic program.

o   Assembly language programming, introduced in 1952, helped  in overcoming these limitations of machine language in the following manner:

1.    By using alphanumeric mnemonic codes instead of numeric codes for the instructions in the instruction set. For example Using ADD instead of 1110. With this feature, programmers can remember easily and use the instructions in the instruction set.

2.    By allowing addresses of fixed storage locations to be represented by alphanumeric names instead of numeric addresses.  For example memory locations 1000, 1001, and 1002 may be represented as FRST, SCND, and ANSR respectively in assembly language program. With this feature, programmer can remember easily and use the storage locations of the data and instructions used in an assembly language program.

3.    By providing additional instructions called pseudo instructions in the instruction set for instructing the system how we want the program to be assembled in computers memory. With this feature a programmer did not keep track of storage locations of the data and instructions while writing an assembly language program.

 

 Advantages of assembly language:

1.    It is easier to understand and use.

2.    Due to the use of mnemonic opcode and symbolic names it is easier to locate and correct errors in assembly language.

3.    Since assembly language programs are easier to understand, it is easier to locate, correct and modify instructions of an assembly language program than a machine language program.

4.    An important advantage of assembly language is that programmers need not keep track of storage locations of data and instructions while writing an assembly language program.

5.    The availability of pseudo instructions for instructing the system how do you want the program to be assembled inside the computer's memory makes assembly language programs easily relocatable because their location can be easily changed by suitably changing the pseudo instructions.

 

Limitations of assembly language:

1.    Machine Dependent:  Since each selection of an assembly language program is translated into exactly one machine language instruction, assembly language programs are machine dependent i.e. assembly language is different from computer to computer and an assembly language program can be executed only on the computer in whose assembly language it has been written.

2.    Knowledge of Hardware Required: Since assembly languages are machine dependent, an assembly language programmer must have a good knowledge of the characteristics and logical structure of his computer to write good assembly language programs.

3.    Machine Level Coding: Assembly language instruction is substituted for one machine language instruction. Hence, like machine language programs, assembly language programs are also time-consuming and difficult.

 

3.   High Level Language:

o   Both machine and assembly language have following limitations:

1.    They are machine dependent.

2.    They require programmers to have a good knowledge of the internal structure of the computer used.

3.    It is difficult, error-prone and time consuming to write programs in machine or assembly language because they deal with machine level coding requiring one instruction to be written for each machine level operation.

 

o   Due to these limitations, machine and assembly languages are often referred as low level programming languages.

 

o   High level programming languages were designed to overcome these limitations of low level programming languages.  They have the following features:

1.    They are machine independent.  A program written in a high-level language can be ported and executed easily on any computer having translator software for the high level language.

2.    They do not require programmers to know anything about the internal structure of the computer on which the high-level language programs are executed.  This allows programmers to concentrate on the logic of the problem rather than be concerned with the details of the internal structure of the computer.

3.    They do not deal with machine level coding. With high level language coding the programmers can write instructions using English words and familiar mathematical symbols and expressions.

o   Some common examples of high level languages   C, C++, Java, etc.

 

Advantages of high level languages:

1.    Machine Independent: A program written in high level language can be executed on many different types of computers with very little or practically no effort of holding it on different computers.

2.    Easier to Learn and Use: High level languages are easier to learn because they are very similar to the natural languages used by us in our day to day life.  They are also easier because a programmer need not know the internal details of a computer for programming in a high level language.

3.    Fewer Errors: While programming in high level language, a programmer need not worry about how and where to store the instructions and data of the program and did not write machine level instructions for the steps to be carried out by the computer. This allows the programmer to concentrate more on the logic of the program under development. All these factors lead to fewer programming errors during program development.

4.    Lower Program Preparation Cost: Writing programs in high level languages requires less time and effort, leading to lower program preparation cost.

5.    Better Documentation: Statements of a program written in high level language are very similar to natural language statements used by us in our day to day life.  Hence, a programmer familiar with the problem domain can easily understand them.  As a result, very few or are practically no separate comment statements are required in programs written in high level languages.  Due to this reason, high level languages are sometimes also referred as self-documenting languages.

6.    Easier to Maintain: Programs written in high level languages are easier to maintain than assembly or machine language programs.  This is because they are easier to understand and hence it is easy to locate, correct and modify instructions whenever desired.  Insertion or removal of certain instructions from a program is also possible without any complication.  Hence major changes can be incorporated with very little effort.

 

Limitations of high level languages:

1.    Low Efficiency: Generally, a program written in high level language has low efficiency than one written in machine or assembly language of the same  because programs written in high level languages result in multiple machine language instructions that may not be optimized, taking more time to execute and require more main memory space.

2.    Less Flexibility: They are less flexible than assembly language because they do not normally have instructions or mechanism to control a computer CPU, memory and registers. This lack of flexibility means that some tasks cannot be done or can be done only with great difficulty in high level language.

No comments:

Post a Comment