fa99 prerequisite quiz

# Computer Organization and Design: The Hardware/Software Interface

• Homework Help
• davidvictor
• 9

This preview shows pages 1–5. Sign up to view the full content.

1 University of California, Berkeley College of Engineering Computer Science Division EECS Fall 1999 John Kubiatowicz Prerequisite Quiz September 1, 1999 CS152 Computer Architecture and Engineering This prerequisite quiz will be used in determining class admissions. The use of is not allowed during this quiz. Good Luck! Your Name: SID Number: Discussion Section: 1 2 3 4 Total

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

2 [ This page left for π ] 3.141592653589793238462643383279502884197169399375105820974944
3 1) Suppose that we start with the following C program for fibonacci: int fib (int n) { /* n >= 0 */ int temp; int sum; if (n <= 1) { return 1; } else { temp = fib (n-1); sum = temp + fib (n-2); return sum; } } Here is a translation of the above program into MIPS assembly language. fib: addi \$v0, \$0, 0 slti \$t0, \$a0, 1 bne \$t0, \$0, end fib1: addi \$sp, \$sp, -12 sw \$a0, 4(\$sp) addi \$a0, \$a0, -1 j fib add \$s0, \$v0, \$0 lw \$a0, 4(\$sp) addi \$a0, \$a0, -2 jr fib1 add \$v0, \$s0, \$v0 end: lw \$ra, 0(\$sp) addi \$sp, \$sp, 12 jr \$ra There are 8 mistakes in this translation. Fix them in the above listing. Assume that MIPS register conventions must be maintained throughout the execution.

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

4 2) Assume that we have a 16 bit system that uses signed, two’s-complement integers.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern