What are the contents of array v right before the sort function enters its outer loop for

Question:

What are the contents of array v right before the sort function enters its outer loop for the first time? Assume that registers $sp, $s0, $s1, $s2, and $s3 have values of 0x1000, 20, 40, 7, and 1, respectively, at the beginning of the main code (right before “li $s0, 5” is executed).


The remaining three problems in this exercise refer to a program that allocates memory for an array, ills the array with some numbers, calls the sort function from Figure 2.27, and then prints out the array. The main function of the program is as follows (given as both C and MIPS code):main() { Main Code in C int *v: int n=5; v=my_alloc(5); my_init(v.n); sort (v.n); main: 11 $50,5 move jal

The my_alloc function is defined as follows (given as both C and MIPS code). Note that the programmer of this function has fallen prey to the pitfall of using a pointer to an automatic variable arr outside the function in which it is defined.my_alloc in C n) { int *my_alloc(int int arr[n]: return arr: } my_alloc: addu SW move s11 sub move move 1wThe my init function is defined as follows (MIPS code): a. my_init: move move L: addi SW addiu addiu bne jr

Figure 2.27Move parameters Outer loop Inner loop Pass parameters and call Inner loop Outer loop sort: forltst: for2tst:exitl: lw Tw 1w 1w Tw addi jr Restoring registers $ra $50, 0($sp) $s1. 4($sp) # restore $s1 from stack $s2,

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Computer Organization And Design The Hardware Software Interface

ISBN: 9780123747501

4th Revised Edition

Authors: David A. Patterson, John L. Hennessy

Question Posted: