CS 207
Midterm 2
Ondich
Due 8:30 AM Wednesday, November 7, 2001

For this exam, you may use your textbook, your notes and assignments, your brain, the Math/CS computers, and whatever psychic powers you possess. If you get stuck, talk to Jeff Ondich, but you may not talk to anyone else about the exam.

Explain and justify your answers. Submit your answers on paper.

  1. (8 points) The following questions concern IEEE 754 32-bit floating point numbers. When I refer to a "representable number," I mean a number whose exact value is one of the values that has a 32-bit IEEE 754 representation.

  2. (8 points) Suppose you have a text file "rogers.txt" containing a letter to Mr. Rogers, congratulating him on his retirement and distinguished career. The text file begins: "Dear Mr. Rogers," with no blank lines or other characters preceding the "Dear." Now, suppose you have a program containing the following code:

    
    long		i;
    ifstream	in( "rogers.txt" );
    
    in.read( &i, sizeof(long) );
    cout << i << endl;
    

    If you compile and run your program on a Macintosh (with a Motorola PowerPC processor), what output does this code fragment produce? If you run it on a Windows machine (with an Intel 80x86 processor), what output does it produce? You may assume that sizeof(long) is 4, and that rogers.txt opens successfully. Explain your answers.

  3. (8 points) Consider the single-cycle datapath shown in Figure 5.21 on page 362 of Patterson and Hennessy. Suppose the PC has value 5000, and the instruction at location 5000 of the instruction memory is "sw $6, 64($7)". Make a copy of the datapath and show the values of as many lines on the datapath as possible. This includes control lines, lines whose values are used during this instruction, lines whose values are not used, etc.

  4. (8 points) Do Problem 6.9 on page 530 of Patterson and Hennessy.

  5. (2 points) Tell me a joke, if you wish. Otherwise, go ahead and collect your 2 points humorlessly.

  6. (8 points) Adders. Assume each NOT gate has a 1 ns propagation delay, and each AND, OR, NAND, NOR, and XOR has a 2 ns delay.