Assignment#1 Solution

5
Assignment # 1 Due Date: 20/09/2011 CSC 221-Computer Organization and Assembly Language BSCS-4 A) Perform the following conversions (Decimal to other bases) a) 458 = ---------------( Base 3) b) 677 = -------------------(Base 5) c) 652 = -------------------(Base 7) d) 4096 = ------------------(Base 16) Solution : e) 121222 b) 10202 c) 1621 d) 1000 B) Convert the following decimal fraction to Binary with maximum of six places to the right of binary point a) 26.78125 b) 194.03125 c) 298.796875 Solution : a) 11010.11001 b) 11000010..100011 c) 100101010.11101 C) Represent these decimal numbers into binary using 8-bit Signed Magnitude, One’s complement and Two’s complement method a) 77 b) -42 c) 119 Solution : a) Signed magnitude: 01001101 One's complement: 01001101 Two's complement: 01001101 b) Signed magnitude: 10101010 One's complement: 11010101 Two's complement: 11010110

Transcript of Assignment#1 Solution

Page 1: Assignment#1 Solution

Assignment # 1

Due Date: 20/09/2011

CSC 221-Computer Organization and Assembly Language

BSCS-4

A) Perform the following conversions (Decimal to other bases)a) 458 = ---------------(Base 3)

b) 677 = -------------------(Base 5)

c) 652 = -------------------(Base 7)

d) 4096 = ------------------(Base 16)

Solution:e) 121222 b) 10202 c) 1621 d) 1000

B) Convert the following decimal fraction to Binary with maximum of six places to the right of binary point

a) 26.78125b) 194.03125c) 298.796875

Solution:a) 11010.11001 b) 11000010..100011 c) 100101010.11101

C) Represent these decimal numbers into binary using 8-bit Signed Magnitude, One’s complement and Two’s complement method

a) 77b) -42c) 119

Solution:a) Signed magnitude: 01001101

One's complement: 01001101Two's complement: 01001101

b) Signed magnitude: 10101010One's complement: 11010101Two's complement: 11010110

c) Signed magnitude: 01110111One's complement: 01110111Two's complement: 01110111

d) Perform the following using Two’ complement method (First convert into binary)

a. 2048-1024b. 256-32c. 512-128

Solution:

Page 2: Assignment#1 Solution

All are powers of two so very simple to convert into binary. Just place number of zeros equal to power of two and place 1 on the left side (as we discussed). Now invert the bits and add 1 to get two’s complement.

e) Suppose the computer uses 4-bits One’s complement ignoring Overflows. What will be the value stored in J at the end of this pseudo code.

J = 0;K = -3;WHILE K ≠ 0

J=J+1K=K-1

END WHILE

Solution:J (Binary) K (Binary)-------------- --- ----------------0 0000 -3 11001 0001 -4 1011 (1100 + 1110) (where last carry is added to sum doing 1's complement addition2 0010 -5 1010 (1011 + 1110)3 0011 -6 1001 (1010 + 1110)4 0100 -7 1000 (1001 + 1110)5 0101 7 0111 (1000 + 1110) (This is overflow -- but you can ignore)6 0110 6 01107 0111 5 0101-7 1000 4 0100-6 1001 3 0011-5 1010 2 0010-4 1011 1 0001-3 1100 0 0000

Let your computer stores numbers as 3-bits. List all the numbers that can be stored using

a. Signed magnitudeb. One's complement

c. Two's complement

Make a table like this

All the numbers those can be represented via Signed Magnitude

f) Simple counting two bits (00,01,10,11) and then adding 1 for –ve and 0 for +ve effectively

Page 3: Assignment#1 Solution

Method doubling the numbers.All the numbers those can be represented via One’s complement method

g) 0 has two representations and other numbers are simple inversions

All the numbers those can be represented via Two’s complement method

h) Same as above but 0 has only one representation

G) Make a comparison creating a table shown below between One’s complement and two’s complement method. Which one is better and why?

One Complement Method Two’s Complement Method

Invert bitsTwo representation of zerosRange smallOld systems

Invert bits +add carryOne representation of zeroRange largeModern systems

H) You have learned Memory Hierarchy. What is rationale behind having so many memories? Describe your answer in your own words just in three lines.I) Give design guidelines of a system having following specificationsa) Memory addressable=1024 bytesb) 16-bits can be transferred in/out at a time.c) Numbers are represented in two’s complement form in 16 bit formatd) Floating point numbers can be expressed in 32-bit format. We want to represent the numbers so big as 1 x 1032

You are required to answer the following just on four lines.1. Address bus width of your system2. Data Bus width3. Range of numbers represented in two’s complement form4. No of bits needed to represent floating point numbers Mantissa and Exponential

part.

Solution:Memory Hierarchy exploits the locality of reference principle and thus

successfully achieve the balance between performance and cost (cost vs. performance trade off)

1. 10 bits2. Data bus16 bits3. Divide the 65535 (range) half for eve and half for +ve

Page 4: Assignment#1 Solution

4. Exponent=5 bits, 1 bit for +ve or –ve and remaining for precision of numbers

Marks are on your effort even if you do wrong. Copied assignments will be marked straight Zero. Write in your own words.

Submission: Submit me hard copy handwritten or printed but your own words. Make sure that the title page shows all information shown in box below..

Assignment # 1

CSC 221-Computer Organization and Assembly Language

<STUDENT NAME HERE><STUDENT REGISTRATION# HERE><STUDENT CLASS AND SECTION# HERE>

SUBMISSION DATE: <DATE AT WHICH YOU ARE HANDING >

DUE DATE: <when was it due>