CS 0447 – Lab 2: Higher/Lower

Description

For this lab, you will create a simple game of higher/lower. The computer will guess a number between 1 and 10, inclusive. You will then enter a guess. The computer will tell you if its number is higher or lower than your guess. It will continue to do this until you have guessed its number.

What to do

This lab requires you to convert a high-level algorithm (albeit a simple one) with loops and if statements into assembly language. We are still covering this material in lecture, so we want to emphasize an incremental approach to the lab to help you to not be overwhelmed by the process (and in the homework projects).

 

Step 1: Write the algorithm in high-level pseudocode in the space below:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: From the class website, download the example rand.asm and run it through MARS.

Read through the comments to try to understand how it works.

Modify the program to print 5 numbers in the range of 1 to 6. (Currently it generates a number in the range 0…99.)

Save this modified file as it will be part of the final demonstration for your lab grade.

 

Step 3: Write a MIPS program that generates a random number in the range [1,10] and displays it.

This is the first incremental step along the way to the full working project. It is a modification of the example.

 

Step 4: Ask for a single guess and display the appropriate message [“higher”, “lower”, “correct”].

Each of your messages will need to be declared as an .asciiz (nul-terminated ascii string) in the .data section.

 

Step 5: Add the loop

Don’t forget to ask MARS to exit the program with the exit syscall.

What to Demo

During your assigned recitation February 11-15, show the TA:

Please note that February 13/14 is the first midterm and so make sure this lab part of your studying if you’re in a Thursday or Friday recitation.