Levels of Programming Languages: Machine Languages (1 Generation Languages)
Levels of Programming Languages: Machine Languages (1 Generation Languages)
Levels of Programming Languages: Machine Languages (1 Generation Languages)
There are many programming languages. The languages are classified into 2 major categories:
1). Low-level programming languages.
2). High-level programming languages.
Each programming language has its own grammatical (syntax) rules, which must be obeyed in
order to write valid programs, just as a natural language has its own rules for forming sentences.
LOW-LEVEL LANGUAGES
These are the basic programming languages, which can easily be understood by the computer
directly, or which require little effort to be translated into computer understandable form.
They include:
1. Machine languages.
2. Assembly languages.
Features of low-level languages
They are machine hardware-oriented.
They are not portable, i.e., a program written for one computer cannot be installed and used
on another computer of a different family.
They use Mnemonic codes.
They frequently use symbolic addresses.
st
Machine languages (1 Generation languages)
Machine language is written using machine codes (binary digits) that consist of 0‟s & 1‟s.
The computer can readily understand Machine code (language) instructions without any
translation.
A programmer is required to write his program in strings of 0‟s & 1‟s, calculate & allocate the
core memory locations for his data and/or instructions.
Different CPU‟s have different machine codes, e.g., codes written for the Intel Pentium
processors may differ from those written for Motorola or Cyrix processors. Therefore, before
interpreting the meaning of a particular code, a programmer must know for which CPU the
program was written.
A machine code instruction is made up of 2 main parts;
(i). An Address (operand):
It specifies the location (address) of the computer memory where the data to be worked
upon can be found.
(ii). A Function (operation) code:
It states to the Control Unit of the CPU what operation should be performed on the
data/item held in the address, e.g., Addition, Subtraction, Division, Multiplication, etc.
Note. The computer can only execute instructions which are written in machine language. This
is because; it is the only language which the computer can understand. Therefore, any program
written in any other programming language must first be translated into machine language
(binary digits) before the computer can understand.
nd
Assembly language (2 Generation Languages).
Assembly languages were developed in order to speed up programming (i.e., to overcome the
difficulties of understanding and using machine languages).
The vocabulary of Assembly languages is close to that of machine language, and their
instructions are symbolic representations of the machine language instructions.
Assembly language programs are easier to understand, use & modify compared to Machine
language programs.
Assembly language programs have less error chances.
To write program statements in Assembly language, the programmer uses a set of symbolic
operation codes called Mnemonic codes.
The code could be a 2 or 3 shortened letter word that will cause the computer to perform specific
operation. E.g., MOV – move, ADD - addition, SUB – subtraction, RD - read.
Example;
RD PAT, 15 (read the value 15 stored in the processor register named PAT)
SUB PAT, 10 (subtract 10 from the value in register PAT)
A program written in an Assembly language cannot be executed/obeyed by the computer
hardware directly. To enable the CPU understand Assembly language instructions, an
Assembler (which is stored in a ROM) is used to convert them into Machine language.
The Assembler accepts the source codes written in an Assembly language as its input, and
translates them into their corresponding computer language (machine code/ object code)
equivalent.
Comments are incorporated into the program statements to make them easier to be understood by
the human programmers.
Assembly languages are machine-dependent. Therefore, a program written in the Assembly
language for a particular computer cannot run on another make of computer.
JAVA
Java is an OOP language that resembles Object C (a simplified form of C++).
The code of Java displays graphics, accesses the network, and interfaces with users via a set of
capabilities known as classes. Classes define similar states & common methods for the behavior
of an object.
JAVA programs are not compiled into machine code; instead, they are converted into a
collection of bytes that represent the code for an abstract Java Virtual machine (VM). A Java
interpreter running on a physical machine is then used to translate those bytes into local actions,
such as printing a string or drawing a button.
Review Questions
1. (a). What is a Programming language?
(b). Explain the two levels of programming languages.
2. (a). What is meant by „Machine language‟?
(b). Explain why machine language programming is so error-prone.
(c). Show the difference between Machine language and Assembly language.
(d). Give two advantages & three disadvantages of Machine language programming.
3. (a). What are High-level languages?
(b). Give the features/characteristics of high-level programming languages.
(c). Describe briefly how a program written in high-level programming language
becomes a machine code program ready for operational use.
(d). Explain the advantages and disadvantages of using a High-level programming
language for writing a program.
(e). List four examples of high-level programming languages. Indicate the application
of each language in computing.
4. (a). What is meant by program portability?
(b). Why are low-level languages not considered to be portable?
5. List 8 factors that need to be considered when selecting a programming language.