Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in MIPS assembly language that implements the DESCENDING bubble

ID: 3637772 • Letter: W

Question

Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words) that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will be used to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that is entered prior to 99999 is considered as a valid input. Zero and negative values are also valid. Empty input sets are also valid. Your program must ask the user if he/she wants to input and sort another array of integers after finishing one round of input and sorting. If yes, then repeat the sort algorithm for the inputs. Use the following algorithm, shown in Java-like syntax:

n=0;

read in;
while in != 99999 {
vals[n]=in;
n++;
read in;
}

for (i=0;i<n-1;i++) {
for (j=0;j<n-1;j++) {
if (vals[j] < vals[j+1]) {
// swap

temp=vals[j];
vals[j]=vals[j+1];
vals[j+1]=temp;
} } }

for (i=0;i<n;i++) {
print vals[i] }
// ask user if he wants to sort another sequence.
Use the following line to set up memory to hold the input:
.data
vals: .space 4000


Important Notes:

1. Program must compile
2. Test cases: Input
i. A descending sorted list
ii. An ascending sorted list
iii. Integers greater than 99999
iv. Negative numbers
v. Mixed- negative and positive
vi. The termination character 99999 is not part of output in any of the above cases
vii. Program asks for a new round of input and sorting.

Explanation / Answer

.data vals: .space 4000 message1: .asciiz "Enter an integer: 9999 to exit " message2: .asciiz "The array contains the following: " next_line: .asciiz " " .text .globl main main: la $a1, vals # $a1 is the base address of the array li $a2, 9 # $a2 = 9; li $t0, 0 # i = 0; li $t1,9999 loop: # cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote