


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CS 61C Midterm Spring 2000
Question 1 (2 points) Convert the binary value 110000001111111111101110 into a) hexadecimal (base 16) b) octal (base 8)
Question 2 (4 points) Assuming a five-bit word length, convert the binary value 11100 to decimal, supposing the representation is a) unsigned b) sign-magnitude c) ones complement d) twos complement
Question 3 (3 points) Decode the following binary numbers as MIPS instructions and give the equivalent MIPS assembly language (MAL) statements. Show memory addresses, if any, in hexadecimal.
Address Value
0x40 00001100101101110000000000100100 0x44 01000110000001000100000110000010 0x48 00000100111000011111111111111110
Question 4 (2 points) In the MIPS procedure-calling convention, there exist a compromise between a pure callee-saved and a pure caller-saved convention. That is, some registers are callee-saved ($s registers) and some are caller-saved ($t registers).
In one English sentence, explain why the MIPS designers chose this mixed strategy rather than either pure callee-saved or pure caller-saved.
Question 5 (4 points) Consider this C struct definition:
struct foo { int a[3]; char b[4]; int *c; } baz;
Suppose that register $16 contains the address of baz.
Here is a fragment of C code: baz.c = baz.a; baz.c[1] = baz.b[2];
Below is a buggy translation into MIPS assembly language. Find and fix all the bugs:
lw $8, 0($16) sw $8, 28($16)
lw $8, 20($16) lw $9, 28($16) sw $8, 4($9)
(Hint: What is A NOR A?)