This assignment has two parts. The first part is to do a MIPS implementation of the second exercise of Lab 9 (the bedtime story exercise). The second part is an exercise in passing functions as parameters (using function pointers).
Take your C implementation of bedtimestory() from Lab 9, and implement it in MIPS assembly. All of the specifications remain the same. Write a main function as well, and use the same sample input and output files.
Your implementation of bedtimestory() must be recursive. A non-recursive implementation of the function will receive zero credit. Name the file with your MIPS code ex1.asm. Test it using your own inputs, and also the sample inputs provided.
You will essentially re-implement bubble sort from Labs 4 and 5, but this time a more general version that can accept as an argument a function to compare two objects. Thus, whether the sorting is to be in ascending order or descending order can be determined simply by passing an appropriate compare function (less-than vs. greater-than).
Understand, compile and run bubble.c and bubble_generic.c. The first program, bubble.c is basically identical to the bubble sort implementation from Lab 4, except that the code has been partitioned into procedures, and it involves floating-point numbers. The second program, bubble_generic.c replaces the simple comparison operation "A > B" with a generic function compare_fn whose actual definition is an argument/parameter passed into the sort routine. Thus, the same bubble sort function can be used to sort floats in increasing order or in decreasing order simply by handing it a different compare function. Carefully study this generic implementation, compile it, and run it. (This implementation comes closer to how you can specify a "compare object/method" to a generic sort routine in C++ or Java.)
Take your C code for bubble_generic, and code the entire program in MIPS assembly, including the main function. You should use single-precision floating-point operands and instructions in MIPS. Name the file with your MIPS code ex2.asm.
Submit your MIPS code by November 9th, 1pm (files ex1.asm and ex2.asm only), using the commands:
% cd ~/comp411lab/lab10 % /home/montek/comp411/bin/submitlab10