Final Exam Program: A Guess-the-Number Game

May 2, 2011

Due Tuesday, May 10 at 11:59PM

Objective

Test your MIPS assembly knowledge.

Requirements

Note: For this assignment, we're going to "pretend" a random number has been generated and stored in a register. (I had trouble getting trap handling to work in MARS the way it does in the SPIM simulator. Here's the example random number generator implementation that I intended for you to use.)

For this last assignment, you will implement a simple version of the first game anyone interested in game programming should implement: guess the number. An example interaction might be as follows:

Welcome to the number guessing game! What is your name?
Nice to meet you, Fred!
Fred
You have three tries left.
Guess a number between 1 and 100 (or enter 0 to quit):
23
Sorry, you guessed incorrectly.
You have two tries left.
Guess a number between 1 and 100 (or enter 0 to quit):
150
That isn't between 1 and 100!
You have two tries left.
Guess a number between 1 and 100 (or enter 0 to quit):
40
Sorry, you guessed incorrectly.
You have one try left.
Guess a number between 1 and 100 (or enter 0 to quit):
50
Sorry, you guessed incorrectly.
You are out of guesses.
You lose!
Thanks for playing this incredibly fun game with me.

Or, in the case of a winning condition:

Welcome to the number guessing game! What is your name?
Fred
Nice to meet you, Fred!
You have three tries left.
Guess a number between 1 and 100 (or enter 0 to quit):
40
WOW! You guessed the correct number.
Thanks for playing this incredibly fun game with me.

And if the user chooses to quit:

Welcome to the number guessing game! What is your name?
Nice to meet you, Fred!
You have three tries left.
Guess a number between 1 and 100 (or enter 0 to quit):
0
Thanks for playing this incredibly fun game with me.

You should manually store the target "random" number in a register of your choice. This will be our "pretend" random number and will make the testing of your program simple.

Grading Criteria (20% of final exam)

Copy your code and paste it into the text area of your blackboard submission. Be sure to review your submission to make sure it is commented and appears properly (eg, has proper line breaks).

Your program must be functionally correct for full credit.