Write a MIPS code to arrange the given set of integers in descending order. You may either assume that the set of integers are provided as initialization of array elements (or) you may ask the user to input the set of integers. You must have the output as
The given integers arranged in descending order is
xx
yy
z
It would be helpful to post the code and corresponding output. Thanks!
.text
.globl main
main:
#printing message 1
li $v0,4
la $a0,msg1
syscall
#read integer for size
li $v0,5
syscall
move $s0,$v0 #storing size into $s0
#printing message 2
li $v0,4
la $a0,msg2
syscall
#reading numbers
la $t0,array
move $t1,$s0
loop:
li $v0,5
syscall
sw $v0,($t0)
#advance $t0 so it point to next index
add $t0,$t0,4
sub $t1,$t1,1
bgt $t1,0,loop
#arrangind in descending order
li $t1,0
for1:
la $t0,array
li $t2,1
for2:
lw $t3,($t0)
add $t0,$t0,4
lw $t4,($t0)
bgt $t3,$t4,skipswap
#swap content
sub $t0,$t0,4
sw $t4,($t0)
add $t0,$t0,4
sw $t3,($t0)
skipswap:
sub $t5,$s0,$t1
add $t2,$t2,1
blt $t2,$t5,for2
add $t1,$t1,1
blt $t1,$s0,for1
#printing arranged numbers
la $t0,array
move $t1,$s0
#printing message
li $v0,4
la $a0,msg3
syscall
printloop:
lw $a0,($t0)
add $t0,$t0,4
sub $t1,$t1,1
li $v0,1
syscall
#printing space
li $v0,11
li $a0,32
syscall
bgt $t1,0,printloop
#code for exit
li $v0,10
syscall
.data
msg1: .asciiz "Enter how many Numbers:"
msg2: .asciiz "Enter numbers:\n"
msg3: .asciiz "Arranged in descending order:\n"
array: .word 0
#snapshot of code
#sample input-output
Write a MIPS code to arrange the given set of integers in descending order. You may...
Write a MIPS code to arrange the given set of integers in descending order. You may either assume that the set of integers are provided as initialization of array elements (or) you may ask the user to input the set of integers. You must have the output as The given integers arranged in descending order is : xx yy z
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 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...
C programing Write a program to sort numbers in either descending or ascending order. The program should ask the user to enter positive integer numbers one at a time(hiting the enter key after each one) The last number entered by the user should be -1, to indicate no further numbers will be entered. Store the numbers in an array, and then ask the user how to sort the numbers (either descending or ascending). Call a function void sortnumbers ( int...
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...
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...
Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...
Code a repetition control structure that: Processes an array of integers in index order to sum its elements. Only odd numbers should be included in the sum and processing should cease when either a negative integer or (be careful) the end of the array is encountered. The array can be any length but you do not have to deal with an empty array. Declare all required variables and give them initial values if required. Display the output using myWindow.writeOutLine(…). You...
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...
Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order (from smallest to largest). You can either get the array as input or hardcode it inside your program.