


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The material for midterm 1 of the cs61c summer 2001 course at the university of california, berkeley. It includes various programming problems that students are expected to solve using c source code, mips assembly instructions, and mal (mips assembly language) instructions. The document also includes short answer questions related to mips architecture and c programming.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Problem #
Rewrite the following C source code using only the MIPS Assembly instructions. Please follow register conventions mentioned in class.
int func1(int a) { int temp; if (a) { temp = a; a++; return(temp+func1(a)); } else return 0; }
Problem #
In the following, some of the statements are incorrect or illegal; cross out any such bad statements. Show in the spaces provided what the remaining print statements will print when the program is executed. Briefly state why the illegal statements are wrong.
int main() { char a = 'A', ur[] = "ORDINALS", b = 'C'; char *alpha = &a, *beta = alpha, *gamma = ur; char **aleph = &alpha, **beth = β
printf("%c\n", *gamma);
printf("%s\n", b);
printf("%c\n", *beta);
printf("%c\n", alpha);
alpha = ur + 1;
printf("%c\n", *(ur + 3));
printf("%s\n", &ur[1]);
ur = alpha;
printf("%c\n", *beta);
beth = &(alpha);
if ( (aleph)[1] == (beth)[1] ) printf("CH is true.\n");
Else printf("CH is false.\n");
return0; }
Problem #
Convert this MIPS machine code into MAL (MIPS Assembly Language) instructions. Your final answers should use the register names, not the numbers(i.e. $t0, not $8) Also, values which represent addresses (if any) should be converted into the full 32 bit address.
ADDRESS: Instructions: 0x10001A00 001000 11101 11101 11111 11111 111100 0x10001A04 101011 11101 11111 00000 00000 000000 0x10001A08 000011 00000 10000 01000 00000 000111 0x10001A0C 000000 00010 00010 00010 00000 100000 0x10001A10 100011 11101 11111 00000 00000 000000 0x10001A14 001000 11101 11101 00000 00000 000100 0x10001A18 000000 11111 00000 00000 00000 001000
Posted by HKN (Electrical Engineering and Computer Science Honor Society) University of California at Berkeley If you have any questions about these online exams please contact mailto:[email protected]