Labels

3/3/08

Here is an implementation of the well known bubble sort algorithm. Reads six integer from user, saves them in a table and the sorts them. It is in MIPS assembly language which you can test using a MIPS simulator. I suggest SPIM which can be found at http://pages.cs.wisc.edu/~larus/spim.html and is free. SPIM works on windows too.

This the code of bubble sort. You just copy and paste in a file and run it using SPIM.

8 comments:

Hi, thanks again for your code, it's very well done! I got your email reply...in the meantime I've been working on 2 different versions of the code, one with characters and the other with floating point numbers. But I still have some problems...mainly this is what I did:for the char I used addi $a1,$zero,2li $v0,8in order to insert a single char without pressing enter and then it sorts ok but the output is still in integer format (int corresponding value of the hex ASCII char code) while if I output withli $v0,4 (as string)it gives the following(null)i think it's something "string related"...but don't know how to figure it out... do you have any ideas?Thanks!!

PS: as soon as i finish a bit of the floating point version i'll post that too...and when it works I can post the full code if you like. ;-)

To print table on every loop you should make a function printtable or something

the code is from the comment#print table to the line above li $v0,10

make this a function (copy paste the code, give a label(e.g. printmytable) and add jr $ra at the endNow in bubble sort code add jal printmytable in every loop(after loop1: or loop2: depends on what you want)