<< Assembly Unit Home

 ! 
 difficulty rating

Check section A.10 for interesting assembler services

More Hints
    Write an algorithm
    Analyze cases
    Break down code to smaller, single function procedures

Objectives
  • Distinguish real and pseudo instructions.
  • Write a simple 30-50 instruction assembly program with 1-2 nested procedures, 2-3 leaf procedures, and utilizing assembler directives and MIPS pseudo-instructions.

Valid HTML 4.01!

 ! 
 ! 
 ! 
SPIM Exercise 5.1
Load 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.2
Write 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.

 ! 
 ! 
 ! 
 ! 
 ! 
SPIM Exercise 5.3 Hide 5.3 hint
Write a procedure to implement insertion sort (see hints to the left). Call the procedure "ins_sort".

  • Input: list of 32-bit signed integers (pass address), and list size (n).
  • Return: address of sorted list.

Look at this C code (source) and the following figure. Use the assembly source file from 5.1 as a template for your solution.