0% found this document useful (0 votes)
19 views25 pages

Copy-CMP 212 LECTURE NOTE

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views25 pages

Copy-CMP 212 LECTURE NOTE

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

INTRODUCTION TO

LOW LEVEL LANGUAGE


(CMP 212)
Lecturer: Abubakar Suleiman
COURSE OUTLINE
1. Introduction to Programming languages
➢Machine Language
➢Low-Level Language
➢ High-Level Language
2. Data Representation & Numbering Systems
➢Binary Numbering Systems
➢Octal Numbering Systems
➢Decimal Numbering Systems
➢Hexadecimal Numbering Systems
COURSE OUTLINE
3. Types of encoding
➢American Standard Code for Information Interchange (ASCII)
➢Binary Coded Decimal (BCD)
➢Extended Binary Coded Decimal Interchange Code (EBCDIC)
4. Mode of data representation
➢Integer Representation
➢Floating Point Representation
5. Computer instruction set
➢Reduced Instruction Set Computer (RISC)
➢Complex Instruction Set Computer (CISC)
INTRODUCTION TO PROGRAMMING LANGUAGES

Programmers write instructions in various programming languages,


some directly understandable by computers and others requiring
intermediate translation steps. These can be divided into three
general types:

✓Machine Language
✓Low Level Language
✓High level Language
MACHINE LANGUAGE
Any computer can directly understand its own machine language.

▪ Machine language is the “natural language” of a computer and such is


defined by its hardware design.

▪ Machine languages generally consist of strings of numbers (ultimately


reduced to 1s and 0s) that instruct computers to perform their most
elementary operations one at a time.

▪ Machine languages are machine dependent (i.e a particular machine


language can be used on only one type of computer).
MACHINE LANGUAGE
Advantages of Machine Language

• It uses computer storage more efficiently


• It takes less time to process in a computer than any other programming
language

Disadvantages of Machine Language

• It is time consuming
• It is very tedious to write
• It is subject to human error
LOW LEVEL LANGUAGE

Machine Language were simply too slow and tedious for most
programmers. Instead of using strings of numbers that computers
could directly understand, programmers began using English like
abbreviations to represent elementary operations. These
abbreviations form the basis of Low Level Language. In low level
language, instructions are coded using mnemonics. E.g. DIV, ADD,
SUB, MOV.
LOW LEVEL LANGUAGE

An assembly language is a low-level language for programming computers. It


implements a symbolic representation of the numeric machine codes and other
constants needed to program a particular CPU architecture.

A utility program called an assembler is used to translate assembly language


statements into the target computer's machine code. The assembler performs a
more or less isomorphic translation (a one-to-one mapping) from mnemonic
statements into machine instructions and data. (This is in contrast with high-
level languages, in which a single statement generally results in many machine
instructions.)
LOW LEVEL LANGUAGE
Advantages of Low Level Language.

• It is more efficient than machine language

• Symbols make it easier to use than machine language

• It may be useful for security reasons

Disadvantages of Low Level Language

• It is defined for a particular processor

• Assemblers are difficult to get

• Although, low level language codes are clearer to humans, they are incomprehensible
to computers until they are translated to machine language
HIGH LEVEL LANGUAGE
Computers usage increased rapidly with the advent of assembly
languages, but programmers still had to use many instructions to
accomplish even the simplest tasks. To speed up the programming
process, high level language were developed in which simple statements
could be written to accomplish substantial tasks. Translator programs
called compilers convert high level language programs into machine
language. High level language allows programmers to write instructions
that look almost like everyday English and contain commonly used
mathematical notations.
HIGH LEVEL LANGUAGE

Advantages of High Level Language

• Compilers are easy to get


• It is easier to use than any other programming language
• It is easier to understand compared to any other programming language
Disadvantages of High Level Language

• It takes more time to process in a computer than any other


programming language
DATA REPRESENTATION AND NUMBERING
SYSTEMS

Most modern computer systems do not represent numeric values


using the decimal system. Instead, they use a binary or two’s
complement numbering system.

To understand the limitations of computer arithmetic, one must


understand how computers represent numbers.
THE BINARY NUMBERING SYSTEM
Most modern computer systems (including the IBM PC) operate
using binary logic.

The binary numbering system works just like the decimal numbering
system, with two exceptions: binary only allows the digits 0 and 1
(rather than 0-9), and binary uses powers of two rather than powers
of ten. Therefore, it is very easy to convert a binary number to
decimal. For each "1" in the binary string, add in 2**n where "n" is
the zero-based position of the binary digit.
THE OCTAL NUMBERING SYSTEM

Octal numbers are numbers to base 8. The primary advantage of the


octal number system is the ease with which conversion can be made
between binary and decimal numbers. Octal is often used as
shorthand for binary numbers because of its easy conversion. The
octal numbering system is shown below;
THE OCTAL NUMBERING SYSTEM
THE DECIMAL NUMBERING SYSTEM
The decimal (base 10) numbering system has been used for so long that
people take it for granted. When you see a number like “123”, you don’t
think about the value 123, rather, you generate a mental image of how
many items this value represents in reality, however, the number 123
represents” 1*102 + 2*101 + 3*100 or 100+20+3 Each digit appearing to
the left of the decimal point represents a value between zero and nine
times an increasing power of ten. Digits appearing to the right of the
decimal point represent a value between zero and nine times an increasing
negative power of ten. e.g. 123.456 means 1*102 + 2*101 + 3*100 + 4*10-1
+ 5*10-2 +6*10-3 or 100 + 20 +3 +0.4 + 0.05 +0.006
THE HEXADECIMAL NUMBERING SYSTEM
A big problem with the binary system is verbosity. To represent the value 202 (decimal) requires eight binary
digits. The decimal version requires only three decimal digits and, thus, represents numbers much more
compactly than does the binary numbering system. This fact was not lost on the engineers who designed
binary computer systems. When dealing with large values, binary numbers quickly become too unwieldy.
Unfortunately, the computer thinks in binary, so most of the time it is convenient to use the binary
numbering system. Although we can convert between decimal and binary, the conversion is not a trivial
task. The hexadecimal (base 16) numbering system solves these problems. Hexadecimal numbers offer the
two features we're looking for: they're very compact, and it's simple to convert them to binary and vice
versa. Because of this, most binary computer systems today use the hexadecimal numbering system. Since
the radix (base) of a hexadecimal number is 16, each hexadecimal digit to the left of the hexadecimal point
represents some value times a successive power of 16. For example, the number 1234 (hexadecimal) is
equal to: 1 * 16**3 + 2 * 16**2 + 3 * 16**1 + 4 * 16**0 or 4096 + 512 + 48 + 4 = 4660 (decimal).
THE HEXADECIMAL NUMBERING SYSTEM

Since converting between hexadecimal and binary is an operation you will

need to perform over and over again, you should take a few minutes and

memorize the table below. Even if you have a calculator that will do the

conversion for you, you'll find manual conversion to be a lot faster and

more convenient when converting between binary and hex.

A comparison of the afore mentioned numbering systems is shown below;


COMPARISON TABLE
MODES OF DATA REPRESENTATION
• INTEGER REPRESENTATION

• Sign-magnitude is the simplest method for representing signed binary numbers. One bit (by

universal convention, the highest order or leftmost bit) is the sign bit, indicating positive or

negative, and the remaining bits are the absolute value of the binary integer. Sign-magnitude is

simple for representing binary numbers, but has the drawbacks of two different zeros and much

more complicates (and therefore, slower) hardware for performing addition, subtraction, and

any binary integer operations other than complement (which only requires a sign bit change). In

sign magnitude, the sign bit for positive is represented by 0 and the sign bit for negative is

represented by 1.
MODES OF DATA REPRESENTATION
• Examples: 1.
• Convert +52 to binary using an 8 bits machine
• Answer: The binary equivalence of 52 is 110100 but 0 is used to represent

positive magnitude, hence 0 is added to the front of this binary equivalence. This

makes a total of 7bits, since we are working on an eight bit machine, we have to

pad the numbers with 0 so as to make it a total of 8bits. Thus the binary

equivalence 0f 52 is 00110100.
MODES OF DATA REPRESENTATION
• 1’s COMPLEMENT: The 1’s complement form of any binary number is simply
by changing each 0 in the number to a 1 and vice versa.

• Examples 1. Find the 1’s complement of -7


• Answer: -7 in the actual representation without considering the machine bit is
1111. To change this to 1’s complement, the sign bit has to be retained and other
bits have to be inverted. Thus, the answer is: 1000. 1 denotes the sign bit. 2. Find
the1’s complement of -7.25 The actual magnitude representation of -7.25 is
1111.01 but retaining the sign bits and inverting the other bits gives: 1000.10
MODES OF DATA REPRESENTATION

• 2’s COMPLEMENT: The 2’s complement of a binary number is the addition of 1


to the rightmost bit of its 1’s complement equivalence.

• Examples 1. Convert -52 to its 2’s complement


• The 1’s complement of -52 is 11001011
• To convert this to 2’s complement we have
11001011
+1
11001100
MODES OF DATA REPRESENTATION
• Addition Of Numbers Using 2’s Complement.
• NOTE: Any negative integer should be converted to it 2’s complement before
performing the addition. While +ve numbers remain as normal.

• Examples 1. Add +9 and +4 for 5 bits machine


= 01001

+ 00100

01101

01101 is equivalent to +13


MODES OF DATA REPRESENTATION
• Addition Of Numbers Using 2’s Complement
• Examples 2. Add +9 and -4 on a 5 bits machine
+9 in its sign magnitude form is 01001
-4 in the sign magnitude form is 10100
Its 1’s complement equivalence is 11011
Its 2’s complement equivalence is 11100 (by adding 1 to its 1’s complement)
Thus addition +9 and -4 which is also +9 + (-4). This gives
01001
+ 11100
100101
Since we are working on a 5bits machine, the last leftmost bit is an off-bit, thus it is neglected. The
resulting answer is thus 00101. This is equivalent to +5

You might also like