=========================preview======================
(ELEC152)ELEC 152midterm1sol.pdf
Back to ELEC152 Login to download
======================================================
Name:__________________________ Student I.D. Number: ______________________
ELEC 152: Computer Organization
(Spring 2005)
Mid-term Examination
Date: 29/3/2005 (Tuesday)
Time: 8:00 - 9:30 p.m.
Lecture Theatre A
1.
There are five questions in this examination. Answer all questions in this question booklet.
2.
Write down your name and student ID number in this page and put your student ID# at the upper right corner of each page in this booklet.
3.
Answer all the questions in the space provided.
Question Number Total Marks Score
1 24
2 20
3 11
4 18
5 16
Total 89
1. Short questions (24 marks)
a.
(1 mark) What is the full name of this term C MFLOPS? Millions Floating-point Operations Per Second
b.
(1 mark) What is the full name of this term C CPI? Cycles Per Instruction
c.
(1 mark) What is the full name of this term C ISA? Instruction Set Architecture
d.
(1 mark) A stack is a LIFO structure. What is the full name of LIFO?
Last In First Out
e.
(3 marks) There are basically 5 steps in executing an instruction in a processor. The following are the 5 steps. Put them in the right execution order.
f.
(2 marks) The right hand sides of the following are the three different types of instruction in MIPS. The left hand sides are the bit format of each type of instruction in MIPS. Put a line to link up correctly the type of instruction and its corresponding instruction format.
a. Write back to register. Step 1. ___c_______________
b. Determine the operand
and get the data Step 2. ___e______________
c. Fetch the instruction
d. Executing the operation Step 3. ___b______________
in ALU
e. Decode the instruction. Step 4. ___d______________
Step 5. ___a_______________
6 bit 5 bit 5 bit 16 bit
6 bit 5 bit 5 bit 5 bit 5 bit 6 bit
R-type
I- type
6 bit 26 bit
J-type
.
g. (2 marks) Why do we need to use the stack when we do a procedure or sub-routine call?
Since we must cover our tracks after our mission is completed, any registers needed by the caller must be restored to the values they contained before the procedure before the procedure was invoked.
h. (6 marks) The following MIPS code shows a fragment of the sub-routine call and the sub-routine code. It contains some errors. Identify these errors and put the corresponding correction next to it.
.
.
jal foo
addi $s1, $s1, 1
..
..
..
foo: sw $ra, 0($sp) # $ra is the return address register, push
# return address addi $sp, $sp, -4 # $sp is the stack pointer register addi $sp, $sp, 4 # pop the return address sw $ra, 0($sp) jr $ra The correct instructions are
foo:
addi $sp, $sp, -4 # $sp is the stack pointer register
sw $ra, 0($sp) # $ra is the return address register, push
# return address
lw $ra, 0($sp)
addi $sp, $sp, 4 # pop the return address
jr $ra