Page 19 - DCAP102_DCAP_401_Foundations of Computer Programming
P. 19

Basic Programming Skills/Foundations of Computer Programming




                    Notes          100111100011101100110101

                                   101100010101010101110000
                                   000000000000000000000000
                                   This is obviously not a very easy language to learn, partly because it is difficult to read and

                                   understand and partly because it is written in a number system with which we are not familiar.
                                   But it will be surprising to note that some of the fi rst programmers, who worked with the fi rst
                                   few computers, actually wrote their programs in binary form as above.
                                   Since human programmers are more familiar with the decimal number system, most of them
                                   preferred to write the computer instructions in decimal, and leave the input device to convert
                                   these to binary. In fact, without too much effort, a computer can be wired so that instead o fusing
                                   long numbers. With this change, the preceding program appears as follows:
                                   10001471
                                   14002041

                                   30003456
                                   50773456
                                   00000000
                                   The set of instruction codes, whether in binary or decimal, which can be directly understood by
                                   the CPU of a computer without the help of a translating program, is called a machine code or
                                   machine language. Thus, a machine language program need not necessarily be coded as strings
                                   of binary digits (1s and 0s). it can also be written using decimal digits if the circuitry of the
                                   computer being used permits this.

                                   Advantages and Limitations of Machine Language

                                   Programs written in machine language can be executed very fast by the computer. This is mainly
                                   because machine instructions are directly understood by the CPU writing a program in machine
                                   language has several disadvantages which are discussed below.
                                   1.  Machine dependent: Because the internal design of every type of commuter is different from
                                       every other type of computer and needs different electrical signals to operate, the machine
                                       language also is different from computer to computer. It is determined by the actual design
                                       or construction of the LU, the control unit, and the size as well as the word length of the
                                       memory unit. Hence, suppose after becoming proficient in the machine code of a particular

                                       computer, a company decides to change to another computer, the programmer may be
                                       required to learn a new machine language and would have to rewrite all the existing
                                       programs.

                                   2.  Diff cult to program: Although easily used by the computer, machine language is diffi cult to
                                       program, it is necessary for the programmer either to memorize the dozens of code numbers
                                       for the commands in the machine’s instruction set or to constantly refer to keep track of the
                                       storage location of data and instructions. Moreover, a machine language programmer must
                                       be an expert who knows about the hardware structure of the computer.

                                   3.  Error code: For writing programs in machine language, since a programmer has to remember
                                       the opcodes and he must also keep track of the storage location of data and instructions,

                                       it becomes very difficult fro him to concentrate fully on the logic of the problem. This
                                       frequently results in program errors. Hence, it is easy to make errors while using machine
                                       code.






          12                               LOVELY PROFESSIONAL UNIVERSITY
   14   15   16   17   18   19   20   21   22   23   24