<< Assembly Unit Home

 ! 
 difficulty rating

Check Section A.10 for interesting assembler services

Objectives
  • Write & use small leaf procedures (used to build next exercise set).
  • Distinguish real and pseudo instructions.

Valid HTML 4.01!

 ! 
 ! 
SPIM Exercise 3.1 20 Minutes
Write a procedure to accept two 32-bit integers as arguments, and return the larger of the two. Call your procedure "max".

Sample input: -8, 12. Return: 12.

 ! 
 ! 
SPIM Exercise 3.2 20 Minutes
Write a procedure to accept two 32-bit integers as arguments, and return the mid-point integer. Call your procedure "mid".

Sample input: 0 and 4, return: 2. Input: 1 and 6, return: 3. Input: 5 and 6, return: 5.

 ! 
 ! 
 ! 
SPIM Exercise 3.3 20 Minutes
Write a procedure to swap two 32-bit integers in memory using their addresses. Call the procedure "swap".

  • Input: address of integer 1, and address of integer 2.
  • Return: no return values.

 ! 
 ! 
 ! 
SPIM Exercise 3.4 25 Minutes
Write a procedure to sum a list of non-negative integers (0, 1, 2, ...). The last element in the input marks the end, and should not be added. Your procedure should return the number of elements in the list. Call your procedure "sum".

Sample list: 78, 95, 65, 45, 30, 80, 74, 68, 64, 60, -1. Procedure sum should return: 659.

 ! 
 ! 
 ! 
SPIM Exercise 3.5 25 Minutes
Write the procedure "smallest" defined as follows:

  • Input: array of 32-bit integers (pass address).
  • Return: address of smallest array element.