Overview of Low-Level & High-Level Computing Languages: Machine, Assembly & High-level, Study Guides, Projects, Research of Microcomputers

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

2016/2017

Uploaded on 06/19/2017

amit.chaudhary
amit.chaudhary 🇬🇧

4

(1)

5 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
g
Introduction
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.
Machine 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
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Overview of Low-Level & High-Level Computing Languages: Machine, Assembly & High-level and more Study Guides, Projects, Research Microcomputers in PDF only on Docsity!

Introduction

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.

Machine 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.

Advantages and disadvantages of machine language

 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:

 There is difficult to modify and correct machine language and also time consuming..

Symbolic/assembly languages

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.

  1. Knowledge of hardware required: due to machine dependent, there needs hardware knowledge for programming.
  2. Machine level coding: in assembly language, instructions are still written at the machine code level. Hence time consuming and difficult like machine language.

High level languages

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:

  1. They are easier to learn than symbolic languages.
  2. They require less time to write.
  3. They are simpler in formats.
  4. They are easier to maintain.
  5. They are easier to understand.
  6. They provide better documentation.
  7. The programs written in such a language can be executed on any computer.
  8. Four or five level instructions are reduced to a single high-level language statement.

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.

Assemblers, compiles and interpreters

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:

  1. To translate mnemonic operation codes into machine code, and symbolic addresses into machine addresses.
  2. To assign absolute address to any symbolic address or label names.
  3. To check each instruction for its correctness and to generate diagnostic messages.
  4. To place each instruction in central memory.
  5. To provide a cross-reference table between all symbolic names used and their absolute addresses.
  6. To provide the necessary linkages for closed subroutines.
  7. To produce the object program on tape, or disk when required.
  8. To produce printed listing of the source and object program with comments.
  9. To inform the control unit (after all the errors have been corrected to execute the program starting from the first instruction of the object code. The main stages of assembling are:
  10. Input source program (in assembly language) through an input device.
  11. Use the assembler to produce an object program in machine language. If errors are found by the assembler, the source program must be modified and corrected. This process of modification and correction should be repeated until all errors found have been corrected.
  12. Load object program into main memory by using a loader.
  13. Execute the object program (by using the operating system) in order to get the desired results.

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:

  1. The user enters the source program through the terminal i.e. keyboard and stores it in the RAM.
  2. The compiler, which is available in RAM is called and asked to perform the translation. The translation process is repeated again and again till all the errors in the source program are identified and corrected.
  3. The compiler transforms the source program into an equivalent object program (in machine language).
  4. The object program thus generated is executed in order to get the desired results. It has to be noted that compilers are not needed to run the program and are needed only to translate it. Also, one compiler is capable of translating source programs written in only one high level language. Thus, a COBOL compiler cannot be used to translate a FORTRAN source program. and again till all the errors in the source program are identified and corrected.

. 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.