Computer Organization and Design: The Hardware/Software Interface

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 [ This page left for π ] 3.141592653589793238462643383279502884197169399375105820974944
Background image of page 2
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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

fa99 prerequisite quiz - University of California, Berkeley...

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

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