Fall 2008 CDA3101
Homework 2
Date assigned: September 30, 2008
Due date: October 14, 2008 (11:59 pm)
Primary TA: Chao Chen ()
All homework must be submitted through E-Learning. No late submission will be accepted. You are required to submit homework in Microsoft word or Adobe pdf format and please make sure that your submitted file can be opened on CISE windows machines.
Your submitted homework answer MUST be typewritten using word processing software. Scanned handwritten submissions will NOT be accepted. Necessary calculation procedure or explanation MUST be provided in your answer.
All homework must be done individually.
Total Points: 100 pts
NAME: ______
UFID: ______
Problem 1 (15 pts)
Suppose 3 computers are being benchmarked to determine which is better for security analysts. The following shows their performance on various benchmark categories.
(times in seconds) / Encryption / Password Cracking / DecryptionComputer 1 / 10 / 30 / 45
Computer 2 / 20 / 41 / 10
Computer 3 / 28 / 48 / 40
a. (7 points) Find the average execution time of each computer through all benchmarks. Which computer is fastest according to these statistics, and what percentage is it faster than the other two computers?
b. (8 points) Suppose encryption is done 5 times as much as decryption, and we’re not going to be doing any password cracking. Compute the weighted average execution time of each computer given this weighting. Which computer is fastest according to these statistics, and how many times faster is it than the other two computers?
Problem 2 (20 points)
Suppose a computer runs at 2GHz. If this computer runs an MPEG-4 video encoder that takes 1 billion instructions and has the following distribution of instructions.
20% Floating point CPI = 3
10% Integer CPI = 1
30% Load CPI = 2
20% Store CPI = 1
15% Branches CPI = 4
5% Other CPI = 1.5
a. (5 points)What is the effective or average CPI for this video encoder?
b. (5 points)How long does it take the encoder to execute?
c. (10 Points) Assume that a smart compiler can reduce the floating-point instructions to half by tripling the integer instructions. Comparing with the original CPI, what is the percentage of CPI improvement? (Hint, you need to recalculate the percentages of all instruction classes.)
Problem 3 (30 points)
1. (8 points) Calculation: Perform the following calculations (by hand) assuming all numbers are 8-bit 2’s complement. Indicate whether overflow occurred (and how you know).
a) 010110102 + 101010102
b) 010110102 - 101010102
(Hint: Negate the 2nd number and add them instead)
2. (12 points) Range: The range of an 8-bit unsigned number is 0-255 (0 to 28-1). List the ranges (both in decimal and in exponential notation (like the 0-255 and the 0 to 28
-1 above) for the following number representations.
a) 32-bit 2’s complement number
b) 32-bit unsigned number
c) 64-bit 2’s complement number
3. (12 points) Floating Point Representation: For the following numbers, write (in binary) the IEEE 754 single-precision representation (32-bits). Remember the magic number (127) that is added to the exponent that we talked about in class. Group the bits by sign, exponent, and fraction like in class. You should do this conversion by hand and show the complete steps.
a) -1
b) 0
c) 13 5/32 (13 and 5/32)
Problem 4(15 points)
Problem 4.10 from the textbook.
Problem 5(25 points)
Consider the MIPS assembly program given below. Refer to Appendix A, section 10
for assembler directives like .data, .text etc used in this program.
.data
plaintext: .asciiz "hello world"
.text
.globl main
main: la $t1, plaintext
loop: lb $t2, 0($t1)
beq $t2, $zero, end
xori $t2, $t2, 0x20
sb $t2, 0($t1)
addiu $t1, $t1, 1
j loop
end: li $v0, 4
la $a0, plaintext
syscall
jr $ra
Note: In case you do not know, ‘syscall’ is a MIPS function used to handle input and output. It receives a few parameters. By setting $v0 to 4, it will print a string, whose address is given by $a0.
a. (8 points) Write the equivalent C or Java code.
b. (4 points) Run the program in SPIM and watch each byte of memory change as you step through each loop iteration. What are the contents of plaintext (in hex) as shown in SPIM data window after the program completes execution?
c. (4 points) What is the equivalent character string in plaintext after the program completes execution.
d. (4 points) What effect does the modified program have on the characters in plaintext?
e. (5 points) What is printed in the SPIM Console window? Why does it show only 2 characters instead of 11 characters, one for each character in plaintext.