Homework II

Tom Kelliher, CS 220

Due Sept. 21, 2007

  1. (30 pts.) Write a MIPS program to sort 10 integer values using selection sort and then print the sorted integers.

  2. (20 pts.) Write a MIPS program to concatenate one string (the source) onto the end of another string (the destination).

For each of these problems, you are to ``compile'' from the C source available on the class Web site. Documentation and neatness matter. You may be penalized if your MIPS source is not adequately commented (for instance, letting me know how you have assigned variables from the C source to MIPS registers) and if your MIPS source is not properly formatted (labels in one set of columns, assembler directives and assembly instructions in another set of columns, and comments properly aligned).

In class, turn in hard copy of your MIPS source code and a sample run of each program. E-mail attachments are not acceptable. You can use the Linux script command to capture your sample run. The basic idea is:

bluebird:~/Class/Cs220/Examples
% script
Script started, file is typescript

bluebird:~/Class/Cs220/Examples
* spim
SPIM Version 7.1 of January 2, 2005
Copyright 1990-2004 by James R. Larus (larus@cs.wisc.edu).
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /usr/local/bin/exceptions.s
(spim) load "addn.spim"
(spim) run
How many inputs? 3
Next input: 5
Next input: 2
Next input: 8
The sum is 15
(spim) quit

bluebird:~/Class/Cs220/Examples
* exit
Script done, file is typescript

bluebird:~/Class/Cs220/Examples
% lpr -P hs123ps typescript

bluebird:~/Class/Cs220/Examples
% rm typescript
The typescript file that was printed with via the lpr command chronicles the terminal session from the time that the script command was executed until the script session was exited via the exit command.



Thomas P. Kelliher 2007-09-13
Tom Kelliher