2. Levels of Programming Languages- Low Level Languages

Post date: 22-Jul-2014 03:12:54

Previous: 1. Introduction- Elementary Programming Principles

Levels of Programming languages

Programming languages are categorized into two levels namely:

1. Low- Level Languages

2. High-Level Languages

Low- Level Languages

A low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture. Generally this refers to either machine code or assembly language. The word "low" refers to the small or nonexistent amount of abstraction between the language and machine language; because of this, low-level languages are sometimes described as being "close to the hardware".

Low-level languages can be converted to machine code without using a compiler or interpreter, and the resulting code runs directly on the processor. A program written in a low-level language can be made to run very quickly, and with a very small memory footprint; an equivalent program in a high-level language will be more heavyweight. Low-level languages are simple, but are considered difficult to use, due to the numerous technical details which must be remembered.

There are two languages used in low level languages namely:

a) Machine language (First generation language)

b) Assembly Language (Second generation language)

Machine language (First generation language)

Sometimes referred to as machine code or object code, machine language is a collection of binary digits or bits that the computer reads and interprets. Machine language is the only language a computer is capable of understanding.

Ø Instructions are written using binary logic

Ø They require many lines of logic to accomplish a task

Ø This very code is hard for humans to understand unless he/she is equipped with special knowledge in machine level programming

Ø Different CPUs have different machine codes this is in reference to the coding schemes we learned earlier like ASCII and EBCDIC

Ø These programs are easy to execute by the CPU but hard to understand by humans

Advantage Machine Language:

The only advantage is that program of machine language run very fast because no translation program is required for the CPU.

Disadvantages Machine Language:

1. It is very difficult to program in machine language. The programmer has to know details of hardware to write program.

2. The programmer has to remember a lot of codes to write a program which results in program errors.

3. It is difficult to debug the program.

Example:

Machine Instruction Machine Operation

00000000 Stop Program

00000001 Turn bulb fully on

00000010 Turn bulb fully off

00000100 Dim bulb by 10%

00001000 Brighten bulb by 10%

00010000 If bulb is fully on, skip over next instruction

00100000 If bulb is fully off, skip over next instruction

01000000 Go to start of program (address 0)

Assembly Language

Sometimes referred to as assembly or ASL, assembly language is a low-level programming language used to interface with computer hardware.

Ø They were developed to overcome the difficulties of understanding and using machine languages

Ø It attempted to make computer languages readable

Ø This language allowed programmers to write programs as a set of symbolic operation codes called Mnemonics- this is a shortened two or three letter words.

Ø Programs written in assembly language require an assembler in order convert them into machine language that the computer can understand.

Ø Assembly language is machine dependent- this means, a program written for one computer cannot be used on another.

The following disadvantages are observed with the assembly languages.

  1. It is time consuming for an assembler to write and then test the program.
  2. Assembly language programs are not portable.
  3. It is necessary to remember the registers of CPU and mnemonic instructions by the programmer.
  4. Several mnemonic instructions are needed to write in assembly language than a single line in high-level language. Thus, assembly language programs are longer than the high language programs.

Example:

MOV r0, #0C ;load base address of string into r0

LOAD: MOV r1,(r0) ;load contents into r1

CALL PRINT ; call a print routine to print the character in r1

INC r0 ;point to next character

JMP LOAD ;load next character

Next: High Level Languages