Question: Problem 1: Write a MIPS assembly language program that features a function called selectionSort. It should accept an integer array (as the address of the

Problem 1: Write a MIPS assembly language program that features a function called selectionSort. It should accept an integer array (as the address of the first word) as well as the length of the array. Your function should then proceed to sort the array using the selection sort algorithm you should have learned in your earlier computer science classes. Write a main function that asks the user to input integers into the array (you can decide how you want to let the user finish his/her input) and then calls your selectionSort algorithm using appropriate stack operations.

Problem 2: Write a function add64 that adds two input unsigned 64 bit integers x and y and returns the unsigned 64 bit integer sum z, i.e. z = x + y. In your main function, you should assume that x, y, and z will be stored in the following 6 registers as follows:

x: upper 32 bits in $t1 lower 32 bits in $t0

y: upper 32 bits in $t3 lower 32 bits in $t2

z: upper 32 bits in $t5 lower 32 bits in $t4

Your main function call should read the values of x and y into the stack, invoke add64, and then return z on the stack.

Also, your function should generate an error only if there is an overflow in the overall 64 bit addition (and not if there is an overflow in the addition of the lower 32 bit components).

Hint: an overflow in the lower 32 bit addition means that there is a carry of 1 to the upper 32 bit addition. Only an overflow in the upper 32 bit addition means that there is a true overflow. One way you can implement this functionality is to have a flag register that is set when an overflow causes an interrupt, which will tell you that you have to carry a 1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!