=========================preview======================
(COMP180)[2010](s)final~2630^_36854.pdf
Back to COMP180 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE &
TECHNOLOGY

Computer Organization (COMP 180)

Spring Semester, 2010


Final Examination
May 22, 2010
Name: Student ID:
Email: Lab Section Number:
Instructions:
1.
This examination paper consists of 15 pages in total, including 7 questions within 11 pages and 4 appendix pages.

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. You can tear off the Appendices only

6.
Calculator and electronic devices are not allowed

7.
The examination period will last for 2 hour and 30 mins.

8.
Stop writing immediately when the time is up.


Question Percentage % Scores
1 20
2 15
3 10
4 15
5 20
6 20
7 10
TOTAL 110

Question: 1 MIPS Programming (20 marks)
Finish a MIPS function that returns the largest integer M which satisfies the following constraint:
1 + 22 + 32 + 42 M2 <= X,
where 0 < X < 231 is stored in register $a0. The return value M should be stored in register $v0. Hints are given beside the boxes for guidance.
find_M:
#Push $ra and $s0 onto the stack
# The box contains as many # instructions as necessary
add $s0, $zero, $zero # initialize the sum $s0 to 0
add $v0, $zero, $zero # initialize M to 0
loop: addi $v0, $v0, 1 # M=M+1

# $t0 = M*M # in at most 2 instructions
add $s0, $s0, $t0 # Sum = Sum + M*M
#Jump to the label done when M is determined, otherwise jump back to the label loop
done:
#clean up the function call
jr $ra # return to caller
Question 2: Computer Arithmetic (15 marks)
Given the following bit pattern, answer questions (a)-(c),
1000 1111 1110 1111 1100 0000 0000 0000
(a)
What is the corresponding number in base 10 assuming that the pattern is a 2s complement integer? You may express the result as the sum of powers of 2. (3 marks)

(b)
What is the corresponding number in base 10, assuming that the pattern is an unsigned integer? You may express the result as the sum of powers of 2. (2 marks)

(c)
What MIPS assembly language code does it represent assuming it is a MIPS instruction? (Refer to appendix 1) (5 marks)

(d)
Multiplication: Compute 0011 (two) x 0101 (two) based on the given hardware. You are required to fill in both the Product and Remark columns of the table. The remarks should briefly describe the operations executed in the corresponding iteration. Fill as many rows as necessary in the table below. (5 marks)



Iteration Multiplicand (M) Product (P) Remark
0 0011 0000 0101 Initial state







Question 3: Performance Evaluation (10 marks)
Suppose there is a program with 100 ins