Final exam -- open book section

24 February, 1994

The entire exam is to be turned in at 2:55PM. Work the closed book section first and turn it in before you consult your books and notes to work on the open book section.

Problem 1. (16 points)

Write a program to evaluate the C statement

     C = X+Y*(Z+C) ;
     E = Z + C ;

in the machine language of a generic accumulator type computer with one address instructions.

Problem 2. (10 points)

Why does the evaluation of the following C statement

     X = A[I]

involve an multiplication by four when implemented in most machine languages?

Problem 3. (10 points)

Which of the following two loops is likely to be faster when both are executed in a pipelined computer architecture

     for (i=0; i<10000; ++i)     for (i=0; i<10000; ++i)
          s = s + A[i] ;              A[i] = s + A[i] ;

Explain your reasoning!

Problem 4. (10 points)

Translate the following expression into RPN:

     (B + C * A) + X + Y * Z