Image goes here
Assignment 3
CptS 260 - Intro to Computer Architecture
Washington State University

CptS 260 Assignment 3

1. (20 pts) Using SPIM, write and test a program that reads in three integers (positive or negative) and prints out the sum of the largest two of the three. Use the SPIM system calls described on pages A-43 through A-45 of http://pages.cs.wisc.edu/~larus/HP_AppA.pdf to read the integers and print the result.

The format of the output should be:

Enter the first integer:
(here's where you enter the first integer
Enter the second integer:
(here's where you enter the second integer)
Enter the third integer:
(here's where you enter the third integer)

The sum of the largest two of these integers is:
(whatever the sum is)
What to turn in: a typed pseudo-code program to solve this problem (5 pts); a printout of the code file you loaded into SPIM (13 pts); a printout of 3 executions of your program (copy and paste or screen scrape from the SPIM console window). The three executions should be for the cases when the first, second, and third numbers are the smallest, respectively (2 pts).

2. (5 pts) Describe how your program could be changed to process arbitrarily many integer inputs and respond with the sum of the largest two. (Don't program this, just tell how it could be done.) Suggest some reasonable ways that you could implement for the user to indicate that the end of the list has been reached.

(c) 2004-2006 Carl H. Hauser           E-mail questions or comments to Prof. Carl Hauser