=========================preview======================
(Comp180)[2004](s)midterm~cs_nfp^_10170.pdf
Back to COMP180 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
Computer Organization (COMP 180)
Spring Semester, 2004
Midterm Examination
March 22, 2004


Name: Solutions Student ID:

Email: Lab Section Number:


Instructions:

1.
This examination paper consists of 12 pages, with 6 questions and 1 appendix reference page.


2.
Please write your name, student ID, email and lab section number on this page.


3.
For each subsequent page, please write your student ID at the top of the page in the space provided.


4.
Please answer all the questions in the spaces provided on the examination paper. You may use the empty spaces on the pages for your rough work and afterwards draw a diagonal line through it to show that it is not part of your answer.


5.
Please read each question very carefully and answer clearly and to the point. Make sure that your answers are neatly written.


6.
Keep all pages stapled together.


7.
The examination period will last for 1 hour and 45 minutes.


8.
Stop writing immediately when the time is up.





Question
Percentage %
Scores

1
10


2
10


3
20


4
20


5
20


6
20


TOTAL
100






Question 1 (10 marks) Basics

Please fill in the following blanks.

a)
The five basic components of a computer are: input ,output ,memory ,datapath ,control. (2.5 marks)





b)
The full name for abbreviation CPI is cycles per instruction . (1.5 marks)


c)
The only complete and reliable measure for performance evaluation is CPU (execution) time . (2 marks)


d)
The addressing mode of MIPS instruction addi $t0, $t1, 4 is immediate addressing , the addressing mode of MIPS instruction add $t0, $t1, $t2 is register addressing . (2 marks)




e)
The processor has some special registers to help supporting procedures, for example, register $ra which holds the return address; and register $sp which points to top of the stack (the position that holds the last-in element). (2 marks)




Question 2 (10 marks) Performance Evaluation

There are three arrays A, B and C, each has 64 elements. The elements of all arrays are defined as word type. We want to add up the corresponding elements of array A, B and put the result in array C. In other words, C[i] = A[i] + B[i].

Following presented two different MIPS code fragments to do this job:
(Assume the base addresses of array A, B and C are stored in registers $t1, $t2 and $t0, respectively.)



Program 1


Program 2


# A[0] = B[0] + C[0]

lw $t3, 0($t1)
lw $t4, 0($t2)
add $t4, $t3, $t4
sw $t4, 0($t0)

# A[1] = B[1] + C[1]

lw $t3, 4($t1)
lw $t4, 4($t2)
add $t4, $t3, $t4
sw $t4, 4($t0)

# ... Repeat for elements
# 2 through 63 ...

#A[63] = B[63] + C[63]

lw $t3, 252(