Introduction To Computing (CS101) : Assignment # 01
Introduction To Computing (CS101) : Assignment # 01
In CPU all the arithmetic operations are performed in binary numbers (0 and 1). Suppose
you have a small CPU which is designed to perform all arithmetic operations using
addition only. You will explain how the following operations will be solved out by the
CPU.
Multiplication of 6 and 2
Addition of 7 and 3
Subtraction of 5 and 4
Answer:
1- Multiplication of 6 and 2:
So (6)10 = (110)2
Binary Number 1 1 0 0
Power of 2 23 22 21 20
(1100)2 =1. 23 + 1. 22 + 0. 21 + 0. 20
(1100)2 = 8 + 4 + 0 + 0
(1100)2 = (12)10
2- Addition of 7 and 3:
So (7)10 = (111)2
So (3)10 = (11)2
Binary Number 1 0 1 0
Power of 2 23 22 21 20
(1010)2 =1. 23 + 0. 22 + 1. 21 + 0. 20
(1010)2 = 8 + 0 + 2 + 0
(1010)2 = (10)10
3- Subtraction of 5 and 4:
So (5)10 = (101)2
So (4)10 = (100)2
Now, adding two times:
Following these addition
rules
101
0+0=0
100
0+1=1
1+0=1
001
1 + 1 = 0, carry over the 1
Binary Number 0 0 1
Power of 2 22 21 20
(001)2 = 0. 22 + 0. 21 + 1. 20
(001)2= 0 + 0 + 1
(001)2 = (1)10
You have an image that can be represented in 8 bits. The image is given below:
(00110011)2
You are required to send this image to someone but not in original form. So, nobody can
extract the features from the image.
So, we will perform following two operations on the image.
1) Masking
You will apply an 8-bit (10101011)2 mask using AND logic operation.
2) Inversion
You will invert the masked image using XOR logic operation.
Answer:
Masking: It is taking (gate) operation bit by bit change and we apply AND Gate operation on
corresponding bits
A B Output
0 1 0
0 0 0
1 1 1
1 0 0
0 1 0
0 0 0
1 1 1
1 1 1
So, after applying mask, we get output = (00100011)2
Inversion: We take 8 bit (00000000) and mask with this 8 bit binary number using XOR Gate
operation.
A B Output
0 0 1
0 0 1
1 0 0
0 0 1
0 0 1
0 0 1
1 0 0
1 0 0