|
Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009
|
|
Lab 4: MIPS Insertion Sort
Due: 11:59 PM, Friday, February 20, 2009
For this lab, you will gain more experience with MIPS programming by
implementing an insertion sort for an array of integers.
- Base your insertion sort MIPS implementation on one of the C
functions found in the file
/cs/terescoj/shared/cs2500/labs/spim-sort/isort.c
. Begin by making sure you understand both versions.
- Write the insertion sort in a subroutine named isort. It
should be called from main, and take two parameters: the
address of the start of the array, and the number of integers in the
array, passed using the standard MIPS conventions for subroutine
calls and register usage. You may base your code on either of the
functions in isort.c.
- Think carefully about how to approach the compound conditional
in the while loop. You may find it helpful to rewrite it first
as a series of if statements with gotos.
- Set up an array in memory and initialize it with a collection of
random values (randomly chosen by you at programming time, not by
SPIM at run time).
- Your main routine should call a subroutine to print out the
initial array, call isort, then print the array again through
another subroutine call. Label your output appropriately.
Submit a single file called isort.s.
Note: During grading, we will replace your array's contents with our
own, so be sure your programs work with a variety of array sizes and
contents. Also, make sure that your programs work in SPIM on the CS
Lab FreeBSD systems, as that is where we will test your programs.
Pay close attention again to appropriate documentation practices. It
is always good to document as you go when doing any kind of
programming, but it especially crucial for assembly language
programming. And don't forget to include your name!
When your program is completed, you may submit it from any CSLab Unix
system with the command:
submit comporg lab4 isort.s