





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to the two fundamental types of computer languages: low-level languages (machine and assembly) and high-level languages. It discusses the differences between these types, their advantages and disadvantages, and the role of compilers, assemblers, and interpreters in translating programs for execution.
Typology: Study Guides, Projects, Research
1 / 9
This page cannot be seen from the preview
Don't miss anything!






A language usually consists of all the verbal or written symbols, grammatical rules and expressions that are used to exchange ideas and information. Communications can take place between individuals or between an individual and a computer. The two BASIC types of languages used in computers are low-level language and high-level languages. Low-level languages are again subdivided into machine and assembly languages. High-level languages may be general purpose or special purpose. They may be either compiler based or interpreter based. High-level languages look similar to our English language and hence are better understood by the programmers rather than the computers. Low-level languages are compatible with the hardware of the computer and consist of binary or mnemonic codes. Hence, low-level languages are understood by the computers in a better manner. It is difficult for the programmer to understand the low level language.
The lowest form of computer language is machine language. In the first generation computers, programs were written only in binary based machine level languages. It has to be remembered that the only language that is understood by the computer is the machine language. However, almost all the programs that are written today are in high level languages. Since computers can understand only machine language, these programs (written in higher level languages) are translated to machine level languages using a software program called compiler/interpreter. Machine language is the most BASIC form of programming and hence explicit instructions are to be given to the machine to perform each operation. Hence, it is necessary to tell the machine where to store numbers in its memory and how to add the numbers and so on. A statement of the form P = Q + R is meaningless in a machine code. If you want to add Q with R, then you have to instruct the machine exactly how to transfer and process the numbers, where to store the result P, etc. Any set of instructions in a machine level language can be divided into the following four categories: Arithmetic, control, input-output and direct use. The functions of these statements are as follows: Arithmetic : Add, subtract, multiply and divide Control : Load, store and jump Input-output : Read and write Direct use : Start, halt and end The arithmetical operations or comparisons are done in the arithmetic logic unit with the use of accumulators. Hence, if you want to add two numbers together, we will need one instruction which will order the control unit to place a number in an accumulator and another instruction to identify the addition operation. Machine language instructions are represented by binary numbers, i.e.,sequences consisting of 0s and 1s. For example, the binary sequence. 001010011010 could represent a 12 bit machine language instruction. The instruction is divided into two parts: operation code (or Op code) and an operand.Op code Operand 0010 10011010 The Op code specifies the operations such as add, multiply, etc. and the operand is the address of the data item that is to be operated upon. Thus, while using a machine language, we have to remember the code numbers for the operations and also keep track of the addresses of all the data items. Hence, machine language is highly complicated and complex and subject to error. Also, the programs written in machine language are machine dependent. That means, a program that has been developed for a particular machine cannot be run on another machine. It is clearly
seen from the above program that coding a program in the binary form is very tedious. Hence, machine language is often coded in hexadecimal codes, which are still quite tedious. The programs written in machine language are also called as Object programs.
Can be executed very fast by a computer. No translation is required. Disadvantage Machine dependent: Machine language differs from computer to computer. Difficult to program: Have to memorize different operations code for programming. Have to know the hardware’s of the computers. Error prone: Must keep track of storage locations of data and information , that makes difficult to concentrate on the logic of the problems, No visual indication of error. Difficult to modify:
To overcome the difficulties of writing programs in machine code, symbolic languages (which are also called as assembly languages) were developed in 1950s and were used extensively in some of the second generation computers. These languages enabled instructions to be written using symbolic codes (called mnemonics) rather than in strings of 0s and 1s. One word (or mnemonic) represented a particular machine language instruction. Once a series of instructions or words were put together to form a program, they are translated (by referencing a symbolic equivalence table) by the computer into their machine language counterparts. Let us assume that the following symbolic operation codes are used (The meaning of the mnemonics are given in brackets). 0001 ADD (Addition) 0010 SUB (Subtraction) 0011 MULT (Multiplication) 0100 DIV (Division) 0101 LDA (Load accumulator with value) 0110 STO (Store contents of accumulator) 0111 IN (Read a value into accumulator) 1000 OUT (Output value in accumulator to output device) 1001 JUN (Jump unconditionally) 1010 JGT (Jump to the address location if the contents of the accumulator are greater than zero) 1011 JNE (Jump to the address location if the contents of the accumulator are not equal to zero). It is clearly seen that symbolic language program is much simpler than the program written in the machine code. Yet assembly language programming has many of the same advantages as machine language programming; i.e., the program has access to and control over the registers, I/O ports and other features of the computer. However, the BASIC disadvantages of having to work with binary, octal or hexadecimal numbers are eliminated.
Unlike symbolic languages, high-level languages can be used with a number of different hardware makes with little or no modifications. Hence, the programming and reprogramming expense is greatly reduced when the program has to be translated to another machine. Other Advantages of high-level languages are as follows:
Obviously, a source program written in a high level language should also be translated into a machine language. The program that performs this operation is called the compiler (which is sometimes also called as a compiler program ) or interpreter. High-level languages may be further subdivided into procedure oriented languages, problem- oriented languages and interactive programming languages. Procedure-oriented languages are useful for some special applications. For example, COBOL is a procedure-oriented language, which is used extensively in business applications. Other examples of procedure-oriented languages are FORTRAN and PL/1.
As discussed already, any program that is not written in machine language has to be translated before it is executed by the computer. We shall see the details of three types of translator programs : assembler, compiler and interpreter now. Assembler Assembler is a program which is used to translate programs written in assembly language into machine code. One machine instruction is generated for each source program instruction. The resulting program can be executed only when the assembly process is completed. The functions of an assembler can be summarized as:
Sometimes compilers are also used to indicate less efficient programming practices such as two branch IF statements. Although it may look that the compiler does the same job as an assembler, it does fat more, particularly in the translation of source statements and the linkage of subroutines. The process of compilation is shown in Fig. 4.2, which consists of the following steps:
. Interpreter High level languages may also be translated using interpreters. Using a compiler, the whole program is translated completely and then the resulting machine language version is executed. Whereas using an interpreter, each instruction is translated and executed. Whereas using an interpreter, each instruction is translated and executed in turn- which means repetitive translation of instructions within loops. In other words, the interpreter takes one source program instruction, translates it into object code and executes it, then takes the next instruction, translates it, and so on. Use of an interpreter can save core space since the interpreter program itself is quite small in size. It also eliminates the need to store the program’s translated object code in the computer. Interpreters are convenient and easy to use because they are totally interactive. The user can sit in front of the terminal and converse with the When he needs to modify or add something; he can do it immediately through the interpreter. When using an interpreter, a programmer gets a feeling that he is directly speaking to a computer and commanding its attention. However it has some disadvantages, program statements that are used multiple times must be translated each time they are executed. Another big drawback of an interpreter is its low speed. Interpreters execute programs at a speed 10-20 times lower than the equivalent machine code generated by an assembler or compiler. In some applications, this low speed is undesirable and also unacceptable. The process of executing programs using an interpreter is shown in Fig. 4.3. It has to be noted that on some micros and personal computers, the interpreter for the BASIC language is resident in ROM and hence there is no need to load them on to the memory.