! difficulty ratingCheck section A.10 for interesting assembler services
More Hints
|
! ! !
SPIM Exercise 5.1Load and run this version of procedure sort from your textbook. Step through the program and note registers PC, $ra, and $sp. Watch the stack. Check the pseudoinstruction expansions against the code in your textbook. ! ! ! !
SPIM Exercise 5.2Write a procedure to implement selection sort. Call the procedure "sel_sort". Procedure inputs: list of 32-bit signed integers (pass address), and list size (n). Use procedures swap and smallest from SPIM Exercises 3.2 and 3.4, respectively. Use the sample list from 3.4 (without the end mark "-1") and the list from 5.1 to test your code.
Algorithm sel_sort
Input: addr_list (addr of list to be sorted), n (list length) Output: addr_list ------------------------------ begin
addr_sublist = addr_list - 4;
end
m = n; while ( m > 1 )
begin
return list_addr
addr_sublist = addr_sublist + 4;
end
addr_smallest = smallest (addr_sublist, m); swap (addr_sublist, addr_smallest); m = m - 1; Some analysis to help understand the algorithm.
|