posrun.s, posrunopt.s. The file posrun.cpp contains
a simple C++ function that finds the length of the longest consecutive
run of positive values in an array. The file posrun.s contains an outline of
MIPS assembly code for this function as might be generated by a
straightforward, non-optimizing compiler. A few lines of code have
already been given.
Your first task is to complete the assembly code for this function,
one instruction per commented line. You should save your assembly
code as posrun.s and test it using the SPIM simulator.
First load main.s, then load posrun.s to
test your program. The correct output for the given data is 4 (the
array values are on the line beginning "list:" in
main.s). You should test your function with other
array values by changing this line.
Your second task is to optimize the loop in this function so as to
decrease the number of instructions executed on each iteration of the
loop. This may involve adding instructions that are
executed either before or after the loop. Save your optimized
assembly code as posrunopt.s. Test using SPIM.
Include comments in your optimized code that indicate what changes
you made and how they improve the code. You may wish to write a C++
function corresponding to your optimized assembly code in order to
clarify any structural changes you made to the code. Save your C++
code in posrunopt.cpp.
Save copies of your files (posrun.s,
posrunopt.s, and optionally posrunopt.cpp)
in your ~/courses/201/assignments directory. Be sure
that your name appears in the comments at
the top of each file that you hand in.