Question: What are the contents of the 5-element array pointed by v right after jal sort returns to the main code? The remaining three problems in
What are the contents of the 5-element array pointed by v right after “jal sort” returns to the main code?
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):
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 1w](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/1/4/3/69465379dceab4ad1698143693431.jpg)

Figure 2.27

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 move move move MIPS Version of the Main Code move jal $a0,$s0 my_alloc. $s1, $v0 $a0,$sl $al, $50 jal my_init move $a0,$sl $al, $50 sort
Step by Step Solution
3.41 Rating (145 Votes )
There are 3 Steps involved in it
To determine the contents of the 5element array pointed by v right after the function sort returns to the main code we need to follow the sequence of ... View full answer
Get step-by-step solutions from verified subject matter experts
