! difficulty ratingCheck Section A.10 for interesting assembler services Objectives
|
! ! SPIM Exercise 3.1 20 MinutesWrite 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
MinutesWrite 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
MinutesWrite a procedure to swap two 32-bit integers in memory using their addresses. Call the procedure "swap".
! ! ! SPIM
Exercise 3.4 25
MinutesWrite 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
MinutesWrite the procedure "smallest" defined as follows:
|