Assignment 2

1 minute read

Due: by the end of the calendar day on Wednesday, September 17, 2025

A Python program to translate

The following Guess the Secret Number Game has been written in Python.

secret_number = 42
guess = 0
num_guesses = 0

while guess != secret_number:
    guess = int(input("Guess the secret number: "))
    num_guesses += 1

    if guess < secret_number:
        print("Too low")
    elif guess > secret_number:
        print("Too high")
    else:
        print("Correct! Number of guesses:", num_guesses)

Here’s an example of a sample run in the console:

Guess the secret number: 27
Too low
Guess the secret number: 90
Too high
Guess the secret number: 50
Too high
Guess the secret number: 40
Too low
Guess the secret number: 45
Too high
Guess the secret number: 42
Correct! Number of guesses: 6

Assignment

Translate the above Python program into MIPS. When you run the program, the user interaction in the console should look like it does when you run the Python program.

Purpose

The purpose of this assignment is to get practice with branching. You don’t need to worry about having a copy of each variable in the .data section - if you keep track of a variable exclusively in a register, that is ok.

Grading

This is a 4-point assignment. See the rubric from the syllabus.

What to turn in

Turn in the following items

  1. Your .asm file which contains your MIPS program
  2. A .txt file (you can use Notepad, TextEdit, or even Visual Studio Code) where you paste in a sample run of your program that shows how it worked when you ran it in MARS

Where to turn it in

Submit your files to the Assignment 2 hand-in form on Blackboard.