Question
MIPS Gnome Sort # Sort a list of numbers using gnome sort. # gnomeSort(a[0..size-1]) { # i := 1 # j := 2 # while
MIPS Gnome Sort
# Sort a list of numbers using gnome sort.
# gnomeSort(a[0..size-1]) {
# i := 1
# j := 2
# while (i
# if (a[i-1] >= a[i])
# i := j
# j := j + 1
# else
# swap a[i-1] and a[i]
# i := i - 1
# if (i = 0) i := 1
# }
# -----
# Procedure must:
# display headers via provided displayHeaders() procedure
# display unsorted list via provided printList() procedure
# sort list
# display sorted list via provided printList() procedure
# -----
# HLL call: gnomeSort(array, len);
# Arguments:
# $a0 - starting address of the list
# $a1 - list length
# $a2 - data set count
# Returns:
# n/a
.globl gnomeSort
.ent gnomeSort
gnomeSort:
jr $ra
.end gnomeSort
Write a MIPS assembly language function, gnomeSort). The function should display some headers, display the unsorted numbers, sort a list of numbers into ascending order (small to large), and display the sorted numbers. The function should call a routine displayHeaders0 and printList0 which is called twice. The displayHeaders0 and printListO routines are provided. To sort the numbers, use the following Gnome sort algorithm: gnome sort (a[o..size-11) 0 j 2 while (iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started