
EEL 4713/5764, Computer Architecture, Spring 2005
Sample Questions for Exam #2
The following questions are intended merely as practice, and to be suggestive of the
approximate style and level of difficulty of questions that might appear on the real exam.
The exact topics of the questions are not guaranteed to be restricted to those shown here.
Any material from the module 6 and 7 lectures and from chapters 3 or 5 (prior to the
multicycle datapath) is fair game for the exam. The exam is open book, open notes. Use
a calculator. Simplify as much as possible, and reduce symbolic answers to plain
numeric form. The real exam will have roughly 7 questions.
1. C to assembly. Below is a C++-language version of the division algorithm on
pp. 184-185 of the textbook, for the case of a 32-bit unsigned dividend and a 16-
bit unsigned divisor. Translate this to MIPS assembly.
// myDivide: Given a 32-bit unsigned dividend and a 16-bit unsigned
// divisor, compute and return the 16-bit unsigned integer quotient and
// also return (in rem) the 16-bit unsigned integer remainder.
unsigned int myDivide(unsigned int dividend, // Number to be divided.
unsigned short divisor, // Number to divide it by.
unsigned short &rem) { // Place to put remainder.
unsigned int
divisor_reg = divisor << 16; // Put divisor in left half of 32b register.
unsigned int quotient = 0; // Quotient register: Initially zero.
int remainder = (int)dividend; // Remainder register: Initially dividend.
for (int i=0; i <= 16; i++) { // Do the following 17 times:
quotient <<= 1; // Make room for a new bit of quotient.
remainder -= divisor_reg; // Trial subtraction of divisor.
if (remainder < 0) // If result is negative,
remainder += divisor_reg; // undo trial subtraction;
else // otherwise,
quotient |= 1; // this bit of the quotient is 1.
divisor_reg >>= 1; } // Shift divisor right to a new position.
rem = (unsigned short)remainder; // Return remainder.
return quotient; } // Return quotient and end.
2. Arithmetic algorithms. In the above division algorithm, show (in a neat table)
the contents of the divisor, remainder, and quotient registers initially and after
each step of the above algorithm for at least the first three loop iterations, in the
case of running it with dividend = 4,000,000,00010 and divisor = 65,00010.
3. Floating point. In standard IEEE 754 single-precision floating-point, what real
number is represented by the word value 7E3616? Write your answer in standard
decimal scientific notation, showing at least six significant figures. Show your
work.
4. ALU control. Given an ALU composed of the 1-bit cells shown in figure B.5.9
(in Appendix B, on the CD), how would all four control bits need to be set to