fa99 prerequisite quiz solution

Computer Organization and Design: The Hardware/Software Interface

Info iconThis preview shows pages 1–3. 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 SOLUTIONS 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: SOLUTIONS 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 Document Right Arrow Icon
2 (1) 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. Fib: addi $v0, $0, 1 # 1, return 1 slti $t0, $a0, 2 # 2, <= 1 bne $t0, $0, end Fib1: addi $sp, $sp, -12 sw $ra, 0($sp) # 3, must save return address sw $a0, 4($sp) sw $s0, 8($sp) # 4, must save “saved” registers before usage addi $a0, $a0, -1 jal fib # 5, subprocedure calls are jal add $s0, $v0, $0 lw $a0, 4($sp) addi $a0, $a0, -2 jal fib # 6, another subprocedure call add
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.

{[ snackBarMessage ]}

Page1 / 7

fa99 prerequisite quiz solution - University of California...

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