This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full 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’scomplement 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 (n1); } } 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.
 Spring '04
 Kubiatowicz
 Computer Architecture

Click to edit the document details