Although we can design a computer to make it understand many different computer languages, every computer understands only one language without using translation program. This language is called machine language of the computer. normally, the machine language of the computer is written as the strings of binary 1s or 0s. The circuitry of a computer can recognize the machine language instructions immediately. It converts them into electricals signals to execute them.
A machine language instruction has the two part format. The first part is operation code that tells the computer what function to perform, and the second part is operand that tells where to find or store the data on which the computer has to perform the function. hence, each instruction tells the computer what operation to perform and the length and locations of the data fields involved in the operation. every computer has a set of operation codes called its instruction set. Each operation code in the instruction set is meant to perform a specific basic operation or function. Typical operations included in the instruction set of a computer are:
1. Algorithm operation.
2. Logical operation.
3. Branch operations (either conditional or un conditional) for transfer of control to the given in the operand field.
4. Data movement operations for moving data between memory locations and resisters.
5. Data movement operations for moving data from input device to memory or from memory to output device.
|
Instruction format. |
In above figure shows a typical single address machine language instruction. Although some computers use only single address instructions, many computers use multiple address instruction that include address of two or more operands. For example, legend and addend may be two operands of an additional methods.
All computers use binary digits for operating internal operations. Hence, most computer's machine language instructions consist of string of binary numbers. For example, a typical program instruction to print a number on a printer might be:
0110001010101110010110010000
A program to add two numbers in memory, and print the result might be:
10001000111100110011
11111100001010101010
10000000101010101100
00000001100000101101
00000000000000000000
Obviously, this language is not easy to use because it is not easy to read and understand, and because it uses a number system, with which are not familiar. However, some of the first programmers, who worked with first few computers, actually wrote their program in binary from as this one.
Since human programmers are more familiar with decimal number system, they prefer to write instructions in decimal, and leave it to the input device to convert them into binary. In fact, without too much effort a computer can be wired so that instead of using long strings of 1s and 0s we can use the more familiar decimal numbers. With this change, the preceding program appears as follows:
100000471
146007770
134063562
105550000
000000000
This set of instructions, whether in binary or decimal, which a computer can understand directly without the help of a translating program is called machine code or machine programming language. Hence, we need not necessarily code a machine language program as string of binary digits (1s and 0s). we can also write it using decimal digits if the computer's circuitry permits this.
Advantages and Limitations of machine language:
A computer can execute programs written in machine language at high and great speed because the computer can understand machine instruction without the need of any translation. However, writing a program in machine language has following disadvantages:
1. Machine dependent:
As the internal design of every computer is different from every other type of computer, machine language also differs from computer to computer. Hence, becoming proficient in the machine language of one type of computer, if a company decides to change another type, its programmer will have to learn new machine language, and would have to rewrite all the existing programs.
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 memorise the dozens of operation code numbers for the commands in the machine's instruction set or refer to a reference card constantly. A programmer must also keep track of storage locations of data and instructions. Moreover, a machine language programmer must be knowledgeable about the hardware structure of the computer.
3. Error prone:
For writing programs in machine language, a programmer has to remember the opcodes and must track of storage locations of data and instructions. This make it very difficult for him/her 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 are the more difficult.
4. Difficult to modify:
It is difficult to currect or modify machine language programs. Checking machine instructions to locate errors is very difficult and time consuming. Similarly, modifying a machine language program later is so difficult that many programmers prefer to code the new logic afresh instead of incorporating necessary modifications in the old program.
In short we rarely use machine language today for writing programs because it is very difficult and time consuming to do so.
Comments
Post a Comment