<< Assembly Unit Home

 ! 
 difficulty rating

Check section A.10 for interesting assembler services

Objectives

Use arithmetic instructins.

Note

Use conventions for floating-point registers:

$f0-$f3 return values from procedure

$f4-$f11 caller-saved temporaries (similar to $t)

$f12-$f15 parameter passing

$f16-$f19 caller-saved temporaries (similar to $t)

$f20-$f31 callee-saved (similar $s).

Valid HTML 4.01!

 ! 
SPIM Exercise 4.1 10 Minutes
Repeat procedure "mid" from SPIM Exercise 3 assuming that the inputs are array indexes. Use the correct arithmetic instructions. Call the new procedure "mid2".

 ! 
SPIM Exercise 4.2 10 Minutes
Repeat procedure "smallest" from SPIM Exercise 3 using the proper instructions for address arithmetic. Why does SPIM expand move using addu (not add)?

 ! 
 ! 
 ! 
SPIM Exercise 4.3 20 Minutes
Change procedure "mid2" to return the mid-point as a real. For example return 5.5 if the inputs are 5,6. Call the new procedure "mid3".

 ! 
 ! 
SPIM Exercise 4.4 15 Minutes
Change procedure "median" from SPIM Exercise 4 to return the median of the list whether the list size is odd or even. Use "mid3" to return the correct median in everycase.

 ! 
 ! 
 ! 
SPIM Exercise 4.5 20 Minutes
Write a procedure "average" which returns the average of a list of non- zero signed 32-bit integers. The procedure should accept the address of the list (array) as input. (Hint: you can use 0 as a special list end mark value.)

 ! 
 ! 
 ! 
SPIM Exercise 4.6 20 Minutes
Change the toUpper procedure from SPIM Exercise 2 to check that the char byte is lower case (in the range ASCII 'a' to 'z') before converting the byte to upper. You must use the bounds check shortcut to check char is in range. Test your code with the string "Lower is NOT upper" (The space and the upper case chars should be skipped).