Vous êtes sur la page 1sur 4

Submitted By:

Introduction to Computing MC 200201449


(CS101)
Assignment # 01

Questions No 01 Marks (10)

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:

This can be interpreted as adding 6 twice so converting decimal to binary

Division by 2 Quotient Reminder Bit #


6/2 3 0 0
3/2 1 1 1

So (6)10 = (110)2

Now, adding 6 two times:


Following these addition
rules
110
0+0=0
110
0+1=1
1+0=1
1100
1 + 1 = 0, carry over the 1

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:

Converting decimal to binary

Division by 2 Quotient Reminder Bit #


7/2 3 1 0
3/2 1 1 1

So (7)10 = (111)2

Division by 2 Quotient Reminder Bit #


3/2 1 1 0

So (3)10 = (11)2

Now, adding two times:


Following these addition
rules
111
0+0=0
011
0+1=1
1+0=1
1010
1 + 1 = 0, carry over the 1

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:

Converting decimal to binary

Division by 2 Quotient Reminder Bit #


5/2 2 1 0
2/2 1 0 1

So (5)10 = (101)2

Division by 2 Quotient Reminder Bit #


4/2 1 0 0
2/2 1 0 1

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

Questions No 02 Marks (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

So, after applying inversion, we get output = (11011100)2

Vous aimerez peut-être aussi