600.102: Foundations of Computer Science

Fall Semester 2005: September 8, 2005 - December 12, 2005

Assignment 4: The MIPS Conspiracy

Out on: October 11, 2005
Due by: October 16, 2005 by 5:59 pm for full credit (11:59 pm for 10% off, hard deadline)
Collaboration: None
Grading: Packaging 10%, Style 10%, Performance 10%, Design 10%, Functionality 60%

Overview

The fourth assignment for 600.102: Foundations of Computer Science covers material from Weeks 4 and 5 and the corresponding reading. It's a little shorter than usual... :-)

Problem 1: Bubbling Around

Your first task is to complete the program you started in lab this week. Your program should be called bubble_sort.s and it should be structured as follows:

If you think you could use another function to your advantage, feel free to introduce one. If you are calling functions from other functions, make sure you handle the stack correctly; you probably won't need this though...

Problem 2: Binary Illusions

Write a MIPS program print_binary.s that reads an integer from the user and prints out its binary representation. For example, if the user enters 45, your program should print 101101; if the user enters 8, your program should print 1000; and so on. You should write a function print_binary that gets the integer to print in $a0 and returns nothing; reading the number should be done in main though.

Deliverables

Please turn in a gzip compressed tarball of your assignment (the extension should be .tar.gz). The tarball should uncompress into a directory cs102-assignment-4-login with login replaced by your Unix login name (so I would use cs102-assignment-4-phf); uncompressing should not create any other files in the current directory. Include a README file that briefly explains what your programs do and contains any other notes you want us to check out before grading (and of course your answers to "written" problems). This file should be a plain Unix text file (not M$ Word, not PDF); it should be formatted in a decent way and it should contain your contact information.

Grading

For reference, here is a short explanation of the grading criteria. Packaging refers to the proper organization of the stuff you hand in, following the guidelines for Deliverables above. Style refers to programming style, including things like consistent indentation, appropriate identifiers, useful comments, etc. Simple, clean, readable code is what you should be aiming for. Performance refers to how fast your program can produce the required results compared to other submissions. Design refers to proper modularization and the proper choice of algorithms and data structures. Functionality refers to your programs being able to do what they should according to the specification given above; if the specification is ambiguous and you had to make a certain choice, defend that choice in your README file.

If your programs do not run on SPIM because of syntax errors you will get no points whatsoever. If your programs fail miserably, i.e. terminate with an exception of any kind, we will take off 10%.

Bonus Problem

If you really want to impress us, try the following. Write a MIPS program guess_this.s that plays the (infamous) "Guess the Number" game. The "player" thinks of a number from 1 to 100, and your program "guesses" that number by asking a few questions:

Think of a number between 1 and 100.
Hit return when you're ready.

Is your number between 1 and 50? n
Is your number between 50 and 75? y
Is your number between 50 and 62? n
Is your number between 63 and 69?
...

And so on, eventually you print the number the "player" thought of (assume he or she answers accurately of course). Actually, there are not too many questions left, but you're writing this, now me. Note that we won't give you extra points for this, but we'll give you extra kudos. :-)

Updated: $Id: assignment-4.html 63 2005-10-12 03:36:36Z phf $ Validate: XHTML CSS
Copyright © 2005 Peter H. Fröhlich. All rights reserved.