main: InsertionSort(numbers - address to integer array,

length - integer)

Insert(numbers - address to integer array,

elementToInsert - integer,

lastSortedIndex - integer) {

integer scores [100]; integer firstUnsortedIndex integer testIndex;
integer n; // # of elements for firstUnsortedIndex = 1 to (length-1) do testIndex = lastSortedIndex;
  Insert(numbers, numbers[firstUnsortedIndex],

firstUnsortedIndex-1);

while (testIndex >=0) AND

(numbers[testIndex] > elementToInsert ) do

InsertionSort(scores, n)
end for
numbers[ testIndex+1 ] = numbers[ testIndex ];
(*) end InsertionSort testIndex = testIndex - 1;
. . .   end while
    numbers[ testIndex + 1 ] = elementToInsert;
end main   end Insert

a) Using the MIPS register conventions, what registers would be used to pass each of the following parameters to InsertionSort:

scores n
   

b) Using the MIPS register conventions, which of these parameters ("numbers", "length", or both of them) should be moved into s-registers?

c) Using the MIPS register conventions, what registers should be used for the local variable "firstUnsortedIndex"?

d) Using the MIPS register conventions, what registers would be used to pass each of the following parameter values to Insert:

numbers numbers[firstUnsortedIndex] firstUnsortedIndex-1
     

e) Using the MIPS register conventions, which of these parameters ("numbers", "elementToInsert", or "lastSortedIndex") should be moved into s-registers?

f) Using the MIPS register conventions, what registers should be used for the local variable "testIndex"?

g) Write the code for main, InsertionSort, and Insert in MIPS assembly language.