PROGRAMMING LANGUAGE
PROGRAMMING LANGUAGE
--------------------------------------------------------------------------------
Programming Language
A Computer System consists of different units with constitute the hardware of the computer.
To simluate the working of the units, instructions are needed.
A set of instructions to be execcuted,by computer, in a particular sequence is called a program.
The language in which these instructions are written are called programming languages.
These languages can be classified into following categories:
- Machine Language
- Assembly Language
- High Level Language
- Machine Language:
The set of instructions written in the machine language is in strings of zeros(0) and ones (1).
Ultimately, the output of any programming language analysis and processing develops in the form of Machine Code.
Machine code is also known as Machine language.
Machine languages are sometimes referred to as 1st generation programming languages.
To understand the development of a machine language, we consider simulated machine of 16 bits of which 4 bits are reserved for operation code and 12 bits for addresses.
Though the machine language program execution time is less,the main disadvantage is that every instruction is to be written in symbols 0 and 1.
The programmer is even supposed to take care of the address of the location where the instruction lies and address of the location where the data lies.
Example of Machine Language:
Our computer has 4 registers and 32 memory locations.
Each instruction is 16 bits.
Here is a machine language program for our simulated computer:
1000000100100101
1000000101000101
1010000100000110
1000001000000110
1111111111111111
Assembly Language:
Some of these difficulties are removed when assembly language is used instead of machine language.
In this language, some mnemonic names are given by variable names.
But the machine understands only the machine language.
So, the Assembly language is translated into machine language through a software which is called Assembler.
It also checks the program for errors.
The set of assembly language instructions is generally a close, but not exact match to the machine language.
An assembly language is a low-level programming language for microprocessors and other programmable devices.
It is not just a single language, but rather a group of languages.
Assembly language implements a symbolic representation of the machine code needed to program a given CPU architecture.
Assembly language is the most basic programming language available for any processor.
With assembly language, a programmer works only with operations that are implemented directly on the physical CPU.
While assembly language is much easier to read and write than machine language, it still suffers from two major problems:
- It is still specific to one architecture, i.e. it is not portable.
- The instructions are still very primitive, so the programs are long and difficult to follow.
We use the mneomnic names for the instructions given to the CPU. These mnemonic names and their meanings are given below:
READ X:
This mnemonic name is used to get the number from the keyboard and stores it in location X.
PRINT X:
This mnemonic name is used to display the content of location X on next line of the screen.
ADD X:
This mnemonic name is used to add the contents of location X to content of accumulator and store the result in accumulator.
SUB X:
This mnemonic name is used to subtract the contents of location X from content of accumulator and store the result in accumulator.
MUL X:
This mnemonic name is used to multiply the contents of location X with the content of accumulator and store the result in accumulator.
SUB X:
This mnemonic name is used to divide the contents of location X by the content of accumulator and store the result in accumulator.
JMP L:
This mnemonic name is used to transfer the control of execution to instruction labelled L
HLT:
This mnemonic name is used to stop the execution.
Example of Assembly Language:
Write a program in assembly language to read marks. Calculate the total marks and print the total along with the marks:
- READ M1
- PRINT M1
- READ M2
- PRINT M2
- LDA M1
- ADD M2
- STORE T
- PRINT T
- HLT
High Level Language:
High level language is different from the machine language.
A high level language does not require the programmer to have a detailed knowledge of computer.
It contains statements that are much like Mathematics and English.
High level languages like C, Fortan, Pascal are consider high level because they are closer to human language which can easily understand and further from machine language.
Like Assembly language, it is considered as low level language just because they are very close to machine language which is difficult to understand.
The main advantage of high-level languages over low-level languages is that they are easier to read, write, and maintain.
Ultimately, programs written in a high-level language must be translated into machine language by a compiler or interpreter.
The first high-level programming languages were designed in the 1950s.
Now there are dozens of different languages, including Ada, Algol, BASIC, COBOL, C, C++, FORTRAN, LISP, Pascal, and Prolog.
Post a Comment