Consider the following C code snippet. // C code void setArray(int num) { int i; int array[10]; for 1 answer below »

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper Order a Different Paper

Consider the following C code snippet.
// C code
void setArray(int num) {
   int i;
   int array[10];
   for (i = 0; i < 10; i = i + 1) {
       array[i] = compare(num, i);
   }
}
int compare(int a, int b) {
   if (sub(a, b) >= 0)
       return 1;
   else
       return 0;
}
int sub(int a, int b) {
   return a – b;
}

Implement the C code snippet in MIPS assembly language. Use $s0 to hold the variable i. Be sure to handle the stack pointer appropriately. The array is stored on the stack of the setArray function (You may see Section 6.4.6 of the textbook for further reference). You may use the MARS MIPS Assembly simulator provided at the URL: http://courses.missouristate.edu/KenVollmar/MARS/download.htm.