=========================preview======================
(COMP180)midterm-01.pdf
Back to COMP180 Login to download
======================================================
STUDENT NUMBER:______________________
THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY COMP180: Computer Organization
Spring Semester, 2001
MIDTERM EXAMINATION March 19, 2001
STUDENT NAME: __________________________________
STUDENT NUMBER: __________________________________
LAB NUMBER: __________________________________
Instructions to Students
1.
There are 6 problems and 9 pages. Check that you have all 9 pages.
2.
Write your name, student number and lab number on this page.
3.
Write your student number on each of the following pages.
4.
Answer all questions in the space provided. Rough work should be done only on the back pages and afterwards drawn a diagonal line through it to show that it is not part of your answer.
5.
Leave all pages stapled together.
6.
The examination period will last for 1 hour and 30 minutes.
7.
Stop writing immediately when the time is up.
For Grading Purpose Only
Problem 1 _______________ / 20
Problem 2 _______________ / 15
Problem 3 _______________ / 20
Problem 4 _______________ / 15
Problem 5 _______________ / 10
Problem 6 _______________ / 20
TOTAL: _______________ / 100
1. (20 points)
(a)
Show the single MIPS instruction or minimal sequence of instructions for this C statement:
x[10] = x[11] + c Assume that c corresponds to register $t0 and the integer array x has a base address of 4,000 (decimal). Note that integers are represented by 32-bit words here.
(b)
Explain why the following instruction cannot be translated into one single MIPS machine
instruction. sw $a0, 80000($t0)
(c)
Translate the statement in b) into exactly two MIPS instructions so that it works.
2. (15 points)
The following code fragment processes an array and produces two important values in register $v0 and $v1. Assume that the array consists of 5000 words indexed 0 through 4999, and its base address is stored in $a0 and its size (5000) in $a1. Describe in one sentence what this code does. Speci.cally, what will be returned in $v0 and $v1?
add $a1, $a1, $a1
add $a1, $a1, $a1
add $v0, $zero, $zero
add $t0, $zero, $zero
outer: add $t4, $a0, $t0
lw $t4, 0($t4)
add $t5, $zero, $zero
add $t1, $zero, $zero
inner: add $t3, $a0, $t1
lw $t3, 0($t3)
bne $t3, $t4, skip
addi $t5, $t5, 1
skip: addi $t1, $t1, 4
bne $t1, $a1, inner
slt $t2, $t5, $v0
bne $t2, $zero, next
add $v0, $t5, $zero
add $v1, $t4, $zero
next: addi $t0, $t0, 4
bne $t0, $a1, outer
3. (20 points)
(a) Give the truth table of the circuit in the following .gure, deduce in one word what is the function of this circuit.
Given the 1-bit ALU shown in the following .gure, answer the questions in part b to f
Cin
(b) Provide the truth table of the adder showing both the Sum and the Cout. Be sure to use labels a, b, and Cin. (c) Write the