You are on page 1of 3

Jordan University of Science and Technology

Faculty of Computer and Information Technology


Department of Computer Engineering

CPE 352 – Computer Architecture


First Semester (2007/2008)

First Exam - Wednesday, October 31, 2007

Instructors: Dr. Mazen Kharbutli and Dr. Abdullah Bataineh

Student’s Name: KEY SOLUTIONS


Student’s ID: Section #:
Exam Instructions:
 This exam consists of 4 pages and 4 questions.
 The total points for this exam are 25 points, which contributes to 25% of your final course grade.
 This exam’s duration is 60 minutes.
 This is a closed-book and closed-notes exam.
 The use of any electronic device (including a calculator) is prohibited.
 Copy your final answers to this answer sheet. Non-copied answers, even if correct, will not be graded.

Answer Sheet:
Q1: (a) (b) (c) (d)
A: 3 seconds 500 6 2

Q2: (a) (b) (c) (d)


FP = 0x3FFFFF
A: 0x85A200 +0.125 2-80
247x(216-1)

(a) (b)

lw $s0, 0($t0) slt $t0, $s1, $s0


lw $s1, 0($t1) bne $t0, $zero, L
Q3: sw $s0, 0($t1)
sw $s1, 0($t0)

instruction 2 instruction 7
(a)
0x01A0582A 0x1540FFF9
$s0 $t5
Q4: (b)
70 30

(c) 66 cycles (d) ∞ (infinite loop)

1
Question #1: [1.5 x 4 = 6 points]

The table below lists the running frequency and CPI of different instruction types for three processors: P1,
P2, and P3.
Processor P1 P2 P3
Frequency 1 GHz 2 GHz 3 GHz
CPI of type A 2 3 4
instructions
CPI of type B instructions 4 5 6
CPI of type C instructions 4 5 X

The three processors are to run the same program which contains 1 Billion dynamic instructions. The
instruction mix of the program is as follows:
Instruction Type Fraction
Type A 50%
Type B 30%
Type C 20%

(a) Find the execution time in seconds of the program when run on processor P1.

(b) Find the MIPS (million instructions per second) of processor P2 when running the program.

(c) The CPI of processor P3 when running the above program is 5.0, find the value of X.

(d) The execution time of the whole program on processor P1 is to be sped up by a factor of 1.25 by
improving the CPI of type B instructions alone. Find the new CPI of type B instructions for processor
P1 to accomplish this.

Question #2: [1.5 x 4 = 6 points]

Consider the following FP representation format to answer the questions below:


 Each FP number is represented using 24 bits that are divided into 3 fields as shown in the figure below.
 The S field holds the sign of the number (0 for positive and 1 for negative).
 The Exponent is a 7-bit signed number (2’s complement representation).
 The Fraction field holds a 16-bit fraction.
 The FP number can be calculated using the following equation: (-1)S x Fraction x 2Exponent
Bits: 23 22 16 15 0
S Exponent Fraction

(a) Represent (-20.25)10 using the FP format above. (Write your result in hexadecimal)

(b) What is the decimal equivalent of the FP number: 0 1111110 1000000000000000

(c) What is the smallest positive number that can be represented? (write your result in decimal)

(d) What is the largest possible number that can be represented? (write your result in decimal)

2
Question #3: [3 x 2 = 6 points]

For each of the following pseudoinstructions, write a minimal sequence of MIPS instructions that
accomplish the same thing. You can only use the MIPS core instructions listed in the left column of Page 4
of this exam. The minimal number of instructions needed is given in parenthesis.

(a) swapm $t0, $t1 swaps the contents of the memory locations M[$t0] and M[$t1] (4 instructions)

(b) bgt $s0, $s1, L if($s0 > $s1) goto L (2 instructions)


10
-20
5
Question #4: [3 + 2 + 1 + -8
1 = 7 points] 12
8
Consider the following MIPS program segment: $a0
-40
instruction 1: L0: lw $t5, 0($a0) -25
instruction 2: slt $t3, $t5, $zero 5
instruction 3: bne $t3, $zero, L1 30
instruction 4: add $s0, $s0, $t5 -1
instruction 5: L1: addi $a0, $a0, 4 9
instruction 6: addi $t2, $t2, -1 4
instruction 7: bne $t2, $zero, L0
0
2
Assume the following initial register values: $s0 = 0
$t2 = 10
Also assume that the register $a0 initially points to the memory segment shown
and that memory grows downwards.

(a) Encode the following instructions into MIPS binary code: (Write your result in
hexadecimal) instruction 2, instruction 7.
1 word
(b) What will the contents of the following registers be at the end of the execution
of the program segment: $s0, $t5

(c) If a processor requires 1 cycle to execute any instruction. How many cycles are
needed to execute the code segment above?

(d) Instruction 7 above was replaced by a new instruction with the following encoding: 0x1000FFFF, find
the new number of cycles needed to execute the whole modified code segment?

You might also like