0% found this document useful (0 votes)
1 views

CS101-Assignment-No-2-Solution-2020

Uploaded by

mishalaslam17
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

CS101-Assignment-No-2-Solution-2020

Uploaded by

mishalaslam17
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

www.vustudy.

com
CS101 Assignment 2 Solution
Idea
Spring 2020
Question # 01 10 marks

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.
i) Multiplication of 6 and 2
ii) Addition of 7 and 3
iii) Subtraction of 5 and 4

Solution:
I. Multiplication of 6 and 2

6*2=12

11
110 (6)
110 (6)
1100 (12)

II. Addition of 7 and 3


111
111 (7)
+11 (3)
1010 (10)

III. Subtraction of 5 and 4

www.vustudy.com
www.vustudy.com
5+(-4)

0101
1100 (2’s complement of 4)
0001

Question # 02 10 marks

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.

Solution:
1) Masking
You will apply an 8-bit (10101011)2 mask using AND logic operation.

AND
(10101011)2

x Y output

0 0 0
(0010011)2 AND
0 1 0
(10101011)2
1 0 0
(00100011)2
1 1 1

1) Inversion

www.vustudy.com
www.vustudy.com
You will invert the masked image using XOR logic operation.

x Y output
XOR (10101011)2
0 0 0

0 1 1
(00110011)2
1 0 1
(0001000)2
1 1 0

www.vustudy.com

You might also like