Exam1Solution File

‫جامعة البترا‬
Petra University
)‫(جامعة خاصة معتمدة‬
(Private Accredited University)
‫كلية تكنولوجيا المعلومات‬
‫قسم علم الحاسوب‬
Faculty of Information Technology
Department of Computer Science
Course Title: Computer Architecture
:‫اسم الطالب‬
601441
:‫الرقم اجلامعي‬
Instructor Name: Dr Kamal Al-Rawi
First Exam
Date: 15-11-2011
Time: 11:00-12:00
2011-2012(1)
:‫الشعبة‬
Part I.: 6
Part II.: 14
:‫الدرجة‬
20 :‫اجملموع‬
Part I. (6 Points) Multiple Choice Questions. Choose the best answer.
Instructions: Use the Answer Table located at the end of this test part for your answers.
Use Capital Letters only for answers-(If non, write additionally the correct
Answer).
If computer A has a clock rate of 200 MHz and executes a program with 1010
instructions in 2 minutes, and computer B has a clock rate of 300 MHz and
executes the same program in 5 minutes (1-2).
1.The cycle per instruction (CPI) for computer A is:
a) 0.4
b) 0.8
c) 1.25
d) 2.4
e) None
2.The performance of computer A relative to computer B is:
a) 2
b) 5
c) 2/5
d) 300
e) 300/120
3.The execution CPU time is:
a) user time b) system time
c) elapse time d) a+b
e) a+c
4.A program or a set of programs used to evaluate computer performance by
computer users is called:
a) work-mark b) performance-mark c) benchmark d) load-mark e) workload.
5.Which of the following instruction is R-type format (register addressing
mode):
a) beq $so,$s1,1200
b) Lw $to,1200($s1) c) addi $to,$s1,1200
d) jr $ra e) none
6.The MIPS instruction that reserves space in the stack for 10 words is:
a) addi $sp,$sp,10
b) addi $sp,$sp,-10
c) subi $sp,$sp,10
d) subi $sp,$sp,40
e) addi $sp,$sp,-40
Q1
D
Q2
E
Q3
D
Q4
E
Q5
D
Computer Architecture- First Exam-2010-2011(2)Page: 1
Q6
E
of 3
Part-II (14 points)
Q1: -(6 points)
a-(3 points)
List three factors that improve CPU performance for a given instruction set.
1- Increase clock rate.
2- Decrease CPI through improvement in processor.
3- Compiler enhancement that lower IC or generate instructions with lower CPI.
b-(3 points)Given two machines A & B. You have the following data:
Program 1
Program 2
Execution time in seconds
Machine A Machine B
2
3
10
5
run%
70%
30%
Which machine you will buy? Explain your decision in details.
Machine A: 2*0.7+10*0.3=4.4 sec
Machine B: 3*0.7+5*0.3=3.6 sec
So, we buy machine B
Q2:- (4 points)
Write the MIPS code and the machine code for the following code segment:
A[i-2]= A[i]+B[i+3];
i, A, and B are associated with registers $s0, $s1, $s2, respectively.
Assume that you have $t0, $t1, $s0, $s1, $s2 only.
Add $t0, $s0,$s0
Add $t0, $t0,$t0
Add $t1,$s1,$t0
LW $s1, 0($t1)
;2*i
;4*i
; full address for A[i] in $t1
;value of A[i] in $s1
Add $s2,$s2,$t0
LW $s2,12($s2)
; full address for B[i] in $s2
;value of B[i+3] in $s2
Add $s0,$s1,$s2
SW $s0,-8($t1)
Computer Architecture- First Exam-2010-2011(2)Page: 2
of 3
Q3:- (4 points)
Write the assembly code for the following segment using the ACCUMULATOR OR
STACK architecture:
D=(A-B)/C+(A+B)*C
Accumulator:
LDA A
ADDA B
MULA C
STA T
LDA A
SUBA B
DIVA C
ADDA T
STA D
STACK
PUSH B
PUSH A
SUB
POP T1
PUSH C
PUSH T1
DIV
POP T2
PUSH A
PUSH B
ADD
PUSH C
MUL
PUSH T2
ADD
POP D
GOOD LUCK
Computer Architecture- First Exam-2010-2011(2)Page: 3
of 3