CC 102: Computer Programming 1: LESSON II: High and Low Level Programming Languages
CC 102: Computer Programming 1: LESSON II: High and Low Level Programming Languages
Objectives
Upon the Completion of Lesson II, 100% of the students can:
17
There are two categories of low-level language: machine code and assembly code.
Each processor manufacturer defines the set of instructions that work with a specific processor (or
processor family), in line with the operations that the processor can carry out. This means that there are
many different processor instruction sets. Each processor instruction set will provide commands to allow
the low-level programmer to move data into and out of the processor and to make use of the processor's
internal registers to minimise data transfer. This means that the low-level programmer must have a good
understanding of the design and capabilities of the processor. A processor instruction set will not have the
same full range of functions that are defined in a high-level language. Multiple instructions may need to
be executed to perform a task that is a single instruction in a high-level language.
Most modern processors use 32 or 64 bits for each instruction. The number of bits a processor handles as
a single unit is known as the word size. You may have noticed this reference to 32-bit or 64-bit in popular
culture: for example, the 1990s games console Nintendo 64 was named this way because it has a 64-bit
processor architecture.
2. Low-level instructions
An opcode (sometimes also referred to as an operation code) is the part of the instruction that specifies
which operation the processor should perform. For example, an opcode might specify the loading or
storing of data.
The operand contains a value, or set of values, relevant to the opcode. The operand can be an actual piece
of data, or it can be a reference to the memory location of the data for the opcode to act on. For example,
when the opcode is a 'store' instruction, the operand contains the memory location where the data should
be stored.
18
Assembly Language
Assembly languages allow programmers to write machine code using a set of ‘mnemonics’ that represent
the binary equivalent in machine code. (The word 'mnemonic' means a system of letters which assists in
remembering something, and it is pronounced "neh-monic".)
In assembly language, the mnemonics are an English language representation of the operation the
machine will perform when executed. For example, the mnemonic LDA might represent the machine
code operation which is used to get a value from main memory and load it into the accumulator. The
accumulator is a register inside the processor.
Assembly language needs to be converted into machine code for it to run. This is done by translating the
source code into the machine code equivalent of the assembly language program. This process is called
assembling and is done by a program called an assembler. At a simplified level, you can imagine that
there is a 1:1 relationship between assembly language and machine code, or in other words, each
assembly language instruction translates into one machine code instruction. The assembly code is not
faster than machine code because the assembly language comes above the machine language in the
hierarchy, so it means that the assembly language has some abstraction from the hardware while machine
language has zero abstraction.
19
Figure 5. Assembly language and its meaning
Machine Language
The machine language (or machine-level language) is a language that consists of a set of instructions
that are in the binary form 0 or 1. As we know that computers can understand only machine instructions,
which are in binary digits, i.e., 0 and 1, so the instructions given to the computer can be only in binary
codes. Creating a program in a machine-level language is a very difficult task as it is not easy for the
programmers to write the program in machine instructions. It is error-prone as it is not easy to understand,
and its maintenance is also very high. A machine-level language is not portable as each computer has its
machine instructions, so if we write a program in one computer it will no longer be valid in another
computer.
Machine code is the only type of programming language that does not need to be translated before being
run, because it is written in binary. Where it is necessary for humans to see and interact with machine
code, hexadecimal is usually used to represent the binary digits, because hexadecimal is easier for humans
to read and understand.
20
The different processor architectures use different machine codes, for example, a PowerPC processor
contains RISC architecture, which requires different code than Intel x86 processor, which has a CISC
architecture.
21
Differences between Machine language and Assembly language
The following are the differences between machine language and assembly language:
The machine-level language comes at the lowest The assembly language comes above the machine
level in the hierarchy, so it has zero abstraction language means that it has less abstraction level
level from the hardware. from the hardware.
The machine-level language is written in binary The assembly language is written in simple
digits, i.e., 0 and 1. English language, so it is easily understandable
by the users.
It does not require any translator as the machine In assembly language, the assembler is used to
code is directly executed by the computer. convert the assembly code into machine code.
Addressing Modes
The operand can often be interpreted in different ways. For example, it could be an actual data value or it
could be a reference to a memory location. For example, is the programmer intending to add the number
3 or the contents of memory location 3?
22
Below is an extended version of the example, where the opcode consists of the instruction to perform
and the addressing mode.
The addressing mode specifies a code that tells the computer how to treat the operand. In the example
shown, an addressing mode of 01 might indicate immediate addressing. In this mode the operand is
treated as data; so the operation would add the value 3 into the accumulator.
A different code, for example 10 could be used to indicate direct addressing. In this mode, the operand
is treated as a memory address; so the operation would add the value stored at the memory location with
address number 3 into the accumulator.
23
High Level Programming Languages
The high-level language is a programming language that allows a programmer to write the programs
which are independent of a particular type of computer. The high-level languages are considered as
high-level because they are closer to human languages than machine-level languages. High-level
programming languages are so-called third-generation languages, whereas low-level languages can be
described as first-generation (machine code) and second-generation (assembly language) languages. This
is because high-level programming languages were invented after machine code and assembly language.
There are many high-level programming languages, and they are grouped by programming paradigm. A
paradigm is a style or way of thinking about how to solve a problem. The high-level languages abstract
many of the steps that the computer needs to take to solve the problem a program addresses. This makes
them much easier for a wide range of people to use than assembly languages.
When writing a program in a high-level language, then the whole attention needs to be paid to the logic of
the problem. A compiler is required to translate a high-level language into a low-level language.
● The high-level language is easy to read, write, and maintain as it is written in English like words.
● The high-level languages are designed to overcome the limitation of low-level language, i.e.,
portability. The high-level language is portable; i.e., these languages are machine-independent.
24
Differences between Low-Level Programming Languages
and High-Level Programming Languages
The following are the differences between low-level language and high-level language:
It requires the assembler to convert the assembly It requires the compiler to convert the high-level
code into machine code. language instructions into machine code.
The machine code cannot run on all machines, so The high-level code can run all the platforms, so
it is not a portable language. it is a portable language.
25
Examples of High Level Languages
1. BASIC (Beginner's All-purpose Symbolic Instruction Code) - Developed in the 1950s for
teaching University students to program and provided with every self-respecting personal
computer in the 1980s, BASIC has been the first programming language for many programmers.
2. Visual Basic - A programming language and environment developed by Microsoft, which was
based on the BASIC language. Visual Basic was one of the first products to provide a graphical
programming environment and a paint metaphor for developing user interfaces.
26
3. C - Developed by Dennis Ritchie at Bell Labs in the mid 1970s. C is much closer to assembly
language than most other high-level languages. The first major program written in C was the
UNIX operating system. The low-level nature of C, however, can make the language difficult to
use for some types of applications.
#include <stdio.h>
int main(void)
printf("hello, world\n");
return 0;
4. C++ - A high-level programming language developed by Bjarne Stroustrup at Bell Labs. C++
adds object-oriented features to its predecessor, C. It is also one of the most popular
programming language for graphical applications, such as those that run in Windows and
Macintosh environments.
#include<iostream>
int main() {
return 0;
27
5. Pascal - A high-level programming language developed by Niklaus Wirth in the late 1960s. The
language is named after Blaise Pascal, a seventeenth-century French mathematician who
constructed one of the first mechanical adding machines. It is also a popular teaching language.
Program HelloWorld(output);
begin
writeLn('Hello, World!')
end.
6. Java - A high-level programming language developed by Sun Microsystems (now Oracle). Java
was originally called OAK, and was designed for handheld devices and set-top boxes. Java is a
general purpose programming language with a number of features that make the language well
suited for use on the World Wide Web.
System.out.println("Hello, World!");
28
References
1. Isaac Computer Science. (2021). High and Low Level Languages. Retrieved 15 September 2021,
from https://isaaccomputerscience.org/topics/programming_languages?
examBoard=all&stage=all
29