Computer Science 61CL - Spring 1997 - Harvey - Midterm 2

Computer Science 61CL - Spring 1997 - Harvey - Midterm 2 -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 61C, Midterm #2, Spring 1997 CS 61C Spring 1997 Midterm #2 Professor Brian Harvey This exam was worth 24 points, and was open book. Problem #1 (4 points) Translate the following procedure to MAL. (Assume that the argument and return value for baz() are integers.) int foo(int x, int y) { return x+baz(y+1); } The arguments and return value are in the standard registers. Don't use unnecessary stack space. Problem #2 (4 points) Mark each of the following true or false. (assume that we are talking about a MIPS system running C or C++.) ___ It will cause a runtime error if a procedure returns a pointer to an array declared as static within the procedure ___ If the compiler chooses to put local variables on the stack, it will need a bigger stack frame that if it chooses to put those local variables in registers $16-$23. ___ The expressions *p and p[0] have the same meaning if p is a pointer to an array of integers ___ The expressions *a and a[0] have the same meaning if a is an array of integers. Problem #3 (2 points) file:///C|/Documents%20and%20Settings/Jason%20Raft. ..20Spring%201997%20-%20Harvey%20-%20Midterm%202.htm (1 of 7)1/27/2007 5:37:07 PM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 61C, Midterm #2, Spring 1997 True of false: A branch instruction poses only control hazards to the pipeline, not data hazards. Explain your answer. Problem #4 (2 points) Suppose we write computer programs to do each of the following computations in floating point arithmetic. Indicate which of the three is most likely to compute the mathematically correct answer, and which is least likely to compute the mathematically correct answer. most likely ____ least likely ____ (((1 + 1/2) + 1/4) + 1/8) . .. most likely ____ least likely ____ 1/r^2 where r is the distance from an electron to the nucleus of its atom, in meters most likely ____ least likely ____ 1/0 Problem #5 (2 points) The following MAL code takes a nonzero value in $8 and computes some function of that
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Computer Science 61CL - Spring 1997 - Harvey - Midterm 2 -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online