Lab 1 - DLD
Lab 1 - DLD
Lab 1 - DLD
Course: Computer Logic and Design Lab Lab Instructor: Tarviha Fatima
Course Instructor: Mr. Salman Mubarik Lab 1
Section: CS-2F2 Total Marks : 20
Objectives of Lab
Students should be able to understand decimal, binary, octal and hexadecimal number systems.
They should get hold on the conventions used for numbers.
Students get to practice Binary Coded Decimals and Alpha Numeric Codes.
They get to exercise performing Arithmetic Operations on different number systems.
1. Number Systems
1.1. Binary Number System
The binary number system is a base 2 system with only two digits: 0 and 1. A binary
number such as “11010” is expressed with a string of 1s and 0s. The decimal
equivalent of binary number can be found by expanding the number into a power
series with base of 2. e.g.
(11010)2 = 1x24 + 1x23 + 0x22 + 1x21 + 0x20
= 16 + 8 + 0 + 2 + 0
= (26)10
The binary system represents numbers using binary digits (bits) where each digit
corresponds to a power of two.
Another Example:
Binary: 1 1 1 0 0 1 0 1
Power of two: 27 26 25 24 23 22 21 20
Decimal: 128 64 32 16 8 4 2 1
– 14/2 = 7 remainder 0
– 7/2 = 3 remainder 1
– 3/2 = 1 remainder 1
= 45056 + 1536 + 80 + 15
= (46687)10
Table 1: Numbers with Different Bases
To avoid writing down long binary words, it is often easier to use larger base
systems. Two commonly-used systems are octal and hexadecimal.
The octal number system is base eight, i.e. values can be represented using an
8-symbol dictionary: 0-7
To convert from binary to octal, binary numbers are grouped on 3-bitswords
such that:
= (20)10
Repeat divide by 8:
3. BCD
It is a Binary Code to represent decimal digits 0-9
It is used by Decimal Number Displays
BCD Addition
(i) Decimal BCD
23: 0010 0011
45: 0100 0101
-----------------------------------
68: 0110 1000
(ii) Decimal BCD
23: 0010 0011
49: 0100 1001
-----------------------------------
72: 0110 1100
Solution:
Decimal BCD
23: 0010 0011
49: 0100 1001
-----------------------------------
72: 0110 1100
6: 0110
-----------------------------------
4. ASCII-8 Code
Numbers 0 to 9
o ASCII 0110000 (30h) to 0111001 (39h)
Alphabets a to z
o ASCII 1100001 (61h) to 1111010 (7Ah)
Alphabets A to Z
o ASCII 1000001 (41h) to 1011010 (5Ah)
Control Characters
o ASCII 0000000 (0h) to 0011111 (1Fh)
In-Lab Problems:
1. List the binary, octal, and hexadecimal numbers of 22, 48, 60 and 72.
2. What is the decimal equivalent of the largest binary integer that can be obtained with
a) 11 bits and
b) 25 bits?
3. Convert the following numbers from the given base to the other three bases listed in the
table:
4. Perform the following conversion by using base 2 instead of base 10 as the intermediate
base for the conversion:
a) (753.4)8 to base 6.
b) (FE2.A)16 to octal
c) (231.3)4 to hexadecimal
d) (2007)10 to base 20.
BCD Problems
(i). 1010011 1110100 1100101 1110110 1100101 0100000 1001010 1101111 1100010 1110011
(ii). 1000111 1101111 0100000 1000010 1100001 1100100 1100111 1100101 1110010 1110011
0100001
a) (24)5 + (53)5
b) (4A)16 + (3F)16
c) 1010100 + 1000011
d) (537)8 – (164)8 Note: Perform subtraction without converting it into another base
e) (1000100)2 – (1010011)2 Note: Use subtraction with borrow
f) (84)16 – (2A)16
g) (15)8 * (44)8
h) (2B)16 * (C)16
i) (11011)2 * (10111)2