mips汇编代写: Project 2 Bubble Sort Again

Overview

Project 2

Bubble Sort Again

Due: Sunday the 8th of April 2018

In this project, you will revisit the first project of the semester: bubble sort. The objective of this project is simply to improve the code from project one by refactoring the logical sections of the code into subroutines. Subroutines are somewhat like functions and facilitate code re-use.

If you did project one, you should already have all the functionality necessary to do this project, you’ll simply have to rearrange what you have and add one or two labels and instructions.

Additionally, the tutorial at the following address may prove helpful:

http://chortle.ccsu.edu/AssemblyTutorial/Chapter-26/ass26_1.html

Keep in mind though that they may only use the basic assembly instructions rather than the extended ones in most places. You don’t have to do that though!

Submission Instructions

Submit only your assembly file for this project. The name of the file must be exactly this: bubble_sort_redux.asm

If you fail to name your file this way, you will almost certainly fail the project since my evaluation program won’t even be able to find your file!

Technical Description and Instructions

Refactor your program so that it still has the same output as project one, but so that the main block looks like this:

main:
    jal print
    jal sort
    jal print
    li $v0, 10
    syscall

The only exceptions to the above layout of the main block are these:
1. You may have code in the main block to print strings which introduce the printing of the array (e.g.

printing ’Unsorted Array:’ before calling print the first time). 2. You may have additional comments
3. You may place the exit code in its own subroutine if you wish

Things to Remember and Helpful Hints:

• Remember that your existing code likely requires a few lines to set things up before the loops; don’t jump directly to the loop labels, put labels above the initialization code and jump to those

1

• Don’t forget to add a jr $ra line at the end of each subroutine
• Don’t forget to make sure that your subroutines obey the subroutine calling conventions

Grading Specification

For your submission to receive a grade of ‘pass’, it must fulfill the following criteria:
• It must be submitted correctly
• I must be able to load your program into MARS and run it with the default settings
• The program should run with no errors and should produce a correct result without crashing • Your main block must be layed out exactly as specified in this printout.

If your program does not work at the time of submission, make sure that you explain in the comments of the code what you have done so far and what is left to be done along with where and why you think you are stuck so that your project can be eligible for resubmission.

2