Download MIPS Homework 3: Computer Organization - Programming Problems and Extra Credit and more Assignments Computer Architecture and Organization in PDF only on Docsity! CDA 3101 Introduction to Computer Organization Summer 2007 Homework #3 Due: at the start of lecture on Thursday 05 July 2007. Write NEATLY or TYPE your answers. Please Xerox your homework before submitting it, so you have verification in case any of your paper(s) is(are) missing. Part I – Programming Problems 1 (10 pts) (a) Write a MIPS program that computes the cube of the difference between two integers x and y: cubed difference = (x - y)3. Show how this program would be implemented as a MIPS instruction cdf $t2, $t0, $t1. Diagram the algorithm and ALU (block diagram only) that would be used to implement this instruction, and identify the computational or data- movement bottlenecks that exist in the ALU or algorithm. Be sure to use the MIPS mfhi and mflo instructions. 2 (20 pts) (a) Use the MIPS program and new MIPS instruction cdf developed in Problem 1, above, to write another MIPS program to compute the mean-cube difference of two n-element arrays a and b of floating point numbers according to the following equation: MCD(a,b) = 1/n · (a(i) - b(i))∑ = n i 1 3 (b) Analyze the execution time of the program you wrote in 2a), above, according to the following table of CPI's, assuming a 4.3 GHz clock rate: Instruction Cycles mfc0, mfhi, mflo 1 slt, slti, sltiu, j 2 lw, sw, bne, beq 3 jr, jal 4 add, addi, sub, addu, addiu, subu 6 mult, multu, div, divu 11 Include in your analysis a graph of execution time as a function of the array length n, for n equal to the first 20 powers of 2. You can produce this graph in MS-Excel, if you wish. 3 (10 pts) Given the following 32-bit patterns: • #1: 1101 0101 1001 1011 0101 1100 1011 0010 • #2: 1100 1110 1001 1010 0111 0101 0100 0001 Derive, and show how you derived, the number or instruction that each bit pattern represents, assuming that they are: • (a) a two's complement integer • (b) an unsigned integer • (c) a single precision floating-point number • (d) a MIPS instruction – if not a valid instruction, then explain why • (e) a 4-character (ASCII) array (8 bits per character, standard ASCII) Show how you arrived at each answer - show your work! If you do not know what standard ASCII encoding is, then search Google using keywords such as ASCII code encoding. 4 (10 pts) Write a MIPS program that implements Booth's algorithm for multiplication (as we discussed in class – refer to viewgraphs, Lecture #13) for 32-bit integers only (no floating point). Store the multiplicand, multiplier, and product in memory and use the appropriate load/store commands to input/output them to/from registers.