The 6 week exam will cover everything assigned (see calendar)... 1. Chapter 1 (including the performance section)

advertisement
The 6 week exam will cover everything assigned (see calendar) or discussed in class from:
1. Chapter 1 (including the performance section)
2. Chapter 2
Below is a sample exam from a previous year – not a complete set of topics.
NOTE NOTE NOTE:
1. This exam is closed-book, closed-notes EXCEPT that you will be provided with a
copy of both sides of the MIPS “green sheet”. Make sure you know how to read this!
2. You may not bring your own copy of the green sheet.
3. Students taking the “practice exam” below did NOT have access to the green sheet.
Therefore, some of the questions we might ask would naturally be different now.
4. In addition to writing MIPS code (as in examples below), be sure that you are also
comfortable with reading and interpreting given MIPS code (see homework
examples).
IC220 Computer Architecture
SAMPLE 6-Week Exam SAMPLE
Last Name ____________________ First Name _________________
Alpha ___________________
Note: This exam is closed-book, closed-notes.
No calculators are permitted.
To receive partial credit, show all work.
UNLESS STATED OTHERWISE, PSEUDO-INSTRUCTIONS MAY BE USED
Page 1 (11 pts)
______________
Page 2 (14 pts)
______________
Page 3 (15 pts)
______________
Page 4 (6 pts)
______________
Page 5 (14 pts)
______________
TOTAL(60 pts)
______________
NOTE: This is an exam that will be given to multiple sections and possibly to students after the
primary exam day. You may not discuss it with anyone until after Fri February 13.
IC220 6wk Exam – SAMPLE
(1 pt) What is the tool that translates from assembly language to machine language?
Answer: ____________________________
(3.5 pts) Now pretend that you are performing a task similar to that program mentioned above. As a first step,
translate the following pseudo-instructions into one or more real MIPS instructions. Where necessary, follow
any conventions that that tool would normally use.
bge $s0, $s1, L2
# If $s0 >= $s1, branch to L2
lw $t0, $s0($t2)
# $t0 = Mem[$s0 + $t2]
(1 pts) Give an EXAMPLE of a particular “ISA” that is in use today.
Answer: ____________________________
(2.5 pts) List the five classic components associated with all computers. No description needed.
1.
2.
3.
4.
5.
(3 pts) Suppose register $s2 holds the base address of array A (an array of 32-bit integers), and register $s1
holds the value of variable X (an integer). Show the MIPS instruction(s) for this C code:
A[4] = A[8] + X;
IC220 6 week Exam – SAMPLE
1
(8 pts) For each of the following, circle whether it is a valid or invalid raw MIPS instruction (count pseudoinstructions as invalid). If invalid, briefly state why (must provide correct reason for credit if invalid).
addi $t0, 13, 17
VALID
INVALID because:
lw $t1, 0($s0)
VALID
INVALID because:
jr $v0, $a0
VALID
INVALID because:
lui $t2, 23
VALID
INVALID because:
(5 pts) In MIPS, there are three different instruction types: R, I, and J. For each instruction below, circle the
appropriate instruction type. Note: some of these instructions you may not have seen before, but you should still
be able to answer the question based on what we know about the instruction types.
1. sw $t0, 8($sp)
Type (circle one):
R
I
J
3. sub $t0, $t1, $t2
Type (circle one):
R
I
J
2. bne $t0, $t1, Label7
Type (circle one):
R
I
J
4. xor $t0, $a0, $a1
Type (circle one):
R
I
J
5. j Label42
Type (circle one):
R
I
J
(1 pts) (circle best answer)
Which type of ISA tends to have a small number of simple, fast instructions? (circle one)
BISC
CISC
LISC
RISC
IC220 6 week Exam – SAMPLE
YISC
2
(2 pts) Machine A is a 4 GHz machine. It requires 10 seconds of actual CPU time to execute a certain program.
How many clock cycles does that program require in total?
(6 pts) The instructions in the instruction set of a particular computer can be categorized into three broad
classes, Class A, Class B and Class C, depending on the average number of cycles that each instruction takes:
CPI
Class A instructions
1
Class B instructions
2
Class C instructions
3
Suppose you are writing a program. You have two different approaches you can take. These two
different approaches use different numbers of instructions, as shown in the table below:
Approach 1
Approach 2
Instruction Counts for each Instruction Class
Class A instructions
Class B instructions
Class C instructions
2
1
2
4
1
1
Circle/provide the correct answers below but remember to show your work.
(1 pt) Which approach executes the most instructions?
APPROACH 1
APPROACH 2
(3 pts) Which approach will be faster and by how much?
APPROACH 1
APPROACH 2
is faster by _________________
(2 pts) What is the CPI for each approach?
CP1 for approach 1 =
CPI for approach 2 =
IC220 6 week Exam – SAMPLE
3
INSTRUCTIONS: If needed on this page and the next, assume the following variable/register mappings:
a – $s0
b – $s1
c – $s2
d – $s3
Where appropriate, be sure to obey register conventions.
It’s fine to use PSEUDO-INSTRUCTIONS (it always is unless we say explicitly not to)
(6 pts) Translate the following C++ code into MIPS assembly.
# Note – assume “b” has some existing value – you don’t know what it is!
d = 0;
for (int a=b; a < 25; a++) {
d = d + a;
}
IC220 6 week Exam – SAMPLE
4
(14 pts) Translate the following C++ code into MIPS assembly. Follow all conventions.
int bellasChoice (int a, int b) {
int score = a + jacob(b);
if (score == 0)
return 17;
else
return edward(score);
}
IC220 6 week Exam – SAMPLE
5
Download