Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 13 Weeks Ago, 1 Day Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write a MIPS assembly language program to sort an array using bubble sort. Your .data section for the array
values should be:
.data
array: .word 20, 30, 10, 40, 50, 60, 30, 25, 10, 5
length: .word 10
.text
.globl main
main:
# MIPS Assembly language program here
li $v0, 10 # system call to exit the program
syscall
The high-level language algorithm for bubble sort is:
for lastUnsortedIndex = (length-1) downto 1 do
for testIndex = 0 to lastUnsortedIndex-1 do
if array[testIndex] > array[testIndex + 1] then
temp = array[testIndex]
array[testIndex] = array[testIndex + 1]
array[testIndex + 1] = temp
end if
end for testIndex
end for lastUnsortedIndex
You can download the MIPS simulator at: http://sourceforge.net/projects/spimsimulator/files/
For Window’s OS, you will want the PCSpim_9.1.9.zip
You should turn in:
a print-out of the MIPS assembly language program, e.g., hw7.s from any text-editor (e.g., WordPad)
a window capture of the PCSpim simulator after running your assembly language program with array
values above. Make sure the sorted array values are visible in the data section of the screen capture.
Â
You can capture this window by (1) right-clicking anywhere in the window to make it the "currently active"
window, (2) while holding down the <Alt> key, press the <PrtScn> key to capture the window into the
Window's clipboard, and (3) open some word processor (Word, Open Office, etc.) and paste the image into
the document. Add your name to this document before printing it.