sp99 prerequisite quiz solution

Computer Organization and Design: The Hardware/Software Interface

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 University of California, Berkeley College of Engineering Computer Science Division EECS Spring 1999 John Kubiatowicz Prerequisite Quiz February 1, 1999 CS152 Computer Architecture and Engineering This prerequisite quiz will be used in determining class admissions. The use of calculators or notes is not allowed during this quiz. Good Luck! Your Name: SID Number: Discussion Section: 1 2 3 4 Total 2 [ This page left for π ] 3.141592653589793238462643383279502884197169399375105820974944 3 1) Assume that we have a 16 bit system that uses signed, two’s-complement integers. Perform the following conversions:-8 10 to base 2: 1111 1111 1111 1000 2 D458 16 to base 2: 1101 0100 0101 1000 2 24 10 to base 16: 0018 16 (1111110110101100) 2 to base 16: FDAC 16 FC34 16 to base 10: 1111 1100 0011 0100 2 =-(0000 0011 1100 1011 2 + 1) =-(0000 0011 1100 1100 2 ) =-(512+256+128+64+8+4)= -972 10 4 2) Suppose that we start with the following C program for factorial: int fact (int n) { if ( n < 1 ) { return 1; } else { return n fact (n-1); } } Here is a translation of the program above into MIPS assembly language. fact: slti $s0 ,$a0,1 ⇐ Callie saves reg! (Use $t0, not $s0) bne $s0 ,$zero,L1 ⇐ Must be “ beq”. ( Also use $t0): beq $t0, $zero, L1 addi $v0,$zero,1 jr $ra L1:subi $sp,$sp,2 ⇐ Need to adjust by 8 (2 words) sw $a0,0($sp) ⇐ Must also save $ra: Insert instruction sw...
View Full Document

This homework help was uploaded on 01/29/2008 for the course CS 152 taught by Professor Kubiatowicz during the Spring '04 term at Berkeley.

Page1 / 9

sp99 prerequisite quiz solution - 1 University of...

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

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