=========================preview======================
(COMP180)[2010](s)midterm2~180^_10174.pdf
Back to COMP180 Login to download
======================================================
Student ID:
HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
Computer Organization (COMP 180) Spring Semester, 2010 Midterm Examination 2 Apr 8, 2010
Name: Solution Student ID:
Email: Lab Section Number:
Instructions:
1.
This examination paper consists of 10 pages with 7 questions.
2.
Please write your name, student ID, email and lab section number on this page.
3.
Please answer all the questions in the spaces provided on the examination paper.
4.
Please read each question very carefully, answer clearly and to the point. Make sure that your answers are neatly written.
5.
Keep all pages stapled together.
6.
Calculator and electronic devices are not allowed
7.
The examination period will last for 1 hour and 45 mins.
8.
Stop writing immediately when the time is up.
Question Percentage % Scores
1 10
2 10
3 12
4 12
5 20
6 16
7 20
TOTAL 100
Student ID:
Question 1 Twos complement (10 marks)
a) Find the 32-bit twos complement binary representation of the decimal number 1025? (2 marks)
0000 0000 0000 0000 0000 0100 0000 0001
b) Find the 32-bit twos complement binary representation of the decimal number -10? (2 marks)
1111 1111 1111 1111 1111 1111 1111 0110
c) What decimal numbers do these twos complement binary numbers represent?
1111 1111 1111 1111 1111 1111 1001 1100 (2 marks)
-100
0000 0000 0000 0000 0000 0000 1100 1000 (2 marks)
200
d) What is the minimum number that can be represented by an 8-bit twos complement binary representation? Please express your answer in decimal format (2 marks)
Page 2 of 10
Question 2 Detecting overflow (10 marks)
a) Suppose X and Y are signed numbers and we add them together (X+Y), under what kind of situation will it overflow happen? Under what kind of situation, the addition will not cause the overflow? (4 marks)
Solution:
(1)
No overflow occurs when: X and Y are of different signs. (2 marks)
(2)
Overflow occurs when: X and Y are of the same sign but the sum X + Y is represented in a different sign. (2 marks)
b) We now do the subtraction X C Y, under what kind of situation will overflow happen? Under what kind of situation, the subtraction will not cause an overflow? (4 marks)
Solution:
(1)
No overflow occurs when: X and Y are of the same sign. (2 marks)
(2)
Overflow occurs when: X and Y are of different signs but X - Y is represented in a different sign from X. (2 marks)
c) Suppose X=010010002 (8 bits signed number) and Y=010000002 (8 bits signed number), during the process of performing the addition X + Y, does an overflow occur? Explain why or why not. (2 marks)
Solution:
Yes, it will cause overflow because X+Y=1000, 10002. (1 mark)
X and Y are of the same sign but X + Y is represented in a different sign. (1 mark)
Question 3 Multiplication (12 marks)
Compute 00111 (two) x 01011 (two) ba