=========================preview======================
(COMP180)2008_s_midterm.pdf
Back to COMP180 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
Computer Organization (COMP 180)
Spring Semester, 2008
Midterm Examination
April 1, 2008
Name: Solutions Student ID:
Email: Lab Section Number:
Instructions:
1. This examination paper consists of 12 pages, with 7 questions and 1 appendix reference page.
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. The examination period will last for 2 hours.
7. Stop writing immediately when the time is up.
Question
Percentage %
Scores
1
10
2
10
3
20
4
12
5
20
6
16
7
12
TOTAL
100
Question 1 Basics (10 marks)
a) For each of the following statements, write down T if it is true and F otherwise. (5 marks)
1) Arithmetic operations in MIPS can directly operate on values stored in memory.
Ans:__F__
2) Increasing throughput always reduces the execution time.
Ans:__F__
3) All MIPS instructions are 32 bits in length.
Ans:__T__
4) The instruction jal sort saves the value of $ra to the program counter before jumping to the instruction labeled sort.
Ans:__F__
5) Each real MIPS assembly instruction corresponds to only a single MIPS machine instruction.
Ans:__T__
b) Please fill in the following blanks. (5 marks)
1) The only complete and reliable measure for performance evaluation is CPU execution time . (1 mark)
2) The addressing mode of MIPS instruction beq $s0, $s1, Label1 is PC-relative addressing
. (1 mark)
3) 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)
4) The result in register $t0 after the execution of the following two MIPS instructions is 0xC3C3C3C3 (use hexadecimal number). (1 mark)
add $t0, $zero, $zero
ori $t0, $t0, 0xC3C3C3C3
Question 2 Simple MIPS Programming (10 marks)
a) The maximum value function is defined as:
Assume x and y are positive numbers. x and y are stored in registers $s1 and $s2 respectively. Fill in the blanks of the following MIPS assembly language segment, which finds the maximum between x and y, then saves the result into register $t0. Note: NO pseudo-code/pseudo-instruction is allowed. Each line holds one instruction. (3 marks)
slt $t1, $s1, $s2
bne
$t1, $zero, max_y
add $t0, $s1, $zero
j finish
max_y: add $t0, $s2, $