Question

MIPS insertion sort program......could really use some assistance


Write a program in MIPS assembly language that implements the DESCENDING insertion 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 beused 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 enteredprior 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/shewants 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.


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.


0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data vectorA: .word 10,40,50,20,30,80,70,60,90,100 .text .globl main main: la $s0, vectorA addi $t1, $zero, 0 addi $t3, $zero, 1 addi $t2, $s0, 0 # $t2 stores the address of v[0] addi $s3, $zero, 0 # i=0 addi $s4, $zero, 9 # j=9 addi $s5, $zero, 0 # k=0 LOOP1: beq $s4, $t1, EXIT slt $t0, $s3,$s4 beq $t0, $t3, LOOP2 bne $t0, $t3, L3 LOOP2: slt $t0, $s3,$s4 bne $t0, $t3, LOOP1 lw $t4, 0($t2) #m lw $t5, 4($t2) #m1 slt $t0,$t5,$t4 beq $t0, $t3, swap addi $s3, $s3, 1 addi $t2, $t2, 4 j LOOP2 swap: addi $s5,$t5,0 addi $t5,$t4,0 addi $t4,$s5,0 sw $t4, 0($t2) #m sw $t5, 4($t2) #m1 addi $s3, $s3, 1 addi $t2, $t2, 4 j LOOP2 addi $s3, $zero, 0 # i=0 L3: sub $s4, $s4, $t3 j LOOP1 EXIT: lw $t6, 0($s0) lw $t7, 4($s0) lw $t8, 8($s0) lw $t9, 12($s0) li $v0,10 syscall # End of file

answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
MIPS insertion sort program......could really use some assistance
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT