CMPS 2240 Lab 15: Implementing Wordle in MIPS Assembly

A Simplified Version of the Popular Word Game

Overview

In this lab, you will complete a simplified implementation of Wordle in MIPS assembly. The base code provides a working framework for a 4-letter word guessing game, but needs implementation of proper feedback mechanics.

Key features to implement:

  1. Basic letter feedback (correct vs incorrect)
  2. Wrong position detection for letters
  3. (Optional) Case-insensitive input handling

Case-sensitivity

  1. The provided code has the hard-coded target of 'CATS'.
  2. It only accepts uppercase letters because the target is hardcoded as uppercase.

Required Files

/home/stu/prodriguezqu/public_html/2240/lab15/*
cp /home/stu/prodriguezqu/public_html/2240/lab15/* . 📋
cp lab15-todo.s mylab15.s 📋

Game Rules

Implementation Tasks

Task 1: Basic Feedback Implementation

  • Currently: All positions are marked as correct ('*')
  • Required: Implement proper marking of incorrect letters with '-'
  • Location: Modify the feedback code in the first check_loop
  • Hint: Only need to modify 2-3 lines of code
Input: DOGS (when target is CATS)
Current output: ****
Required output: ---*

Task 2: Wrong Position Detection

  • Required: Implement the second_pass section to detect correct letters in wrong positions
  • Mark these positions with '+' instead of '-'
  • Must handle cases where a letter appears multiple times
  • Hint: Need to check each non-matching letter against all target word positions
Input: TACO (when target is CATS)
Current output: -*--
Required output: +*+-

Task 3 (Additional Challenge)

  • Make the input handling case-insensitive
  • Convert lowercase letters to uppercase before processing
  • Hint: ASCII manipulation (difference between cases is 32)

Testing Your Implementation

Target word: CATS

Input: CATS
Expected: ****    (Perfect match)

Input: TACO
Expected: +*+-    (T and A are in word)

Input: DOGS
Expected: ---*    (Only S matches)

MIPS Tips

Register Usage

  • $t0-$t3: Loop counters and temporary storage
  • $t4-$t6: Character comparisons
  • $t7-$t9: Additional comparisons for wrong position checks

ASCII Values

  • Uppercase letters: 65 ('A') to 90 ('Z')
  • Lowercase letters: 97 ('a') to 122 ('z')
  • Convert lowercase to uppercase: Subtract 32

Common Pitfalls

  1. Forgetting to null-terminate strings
  2. Not preserving register values between loop iterations
  3. Double-counting letters in wrong position checks

Compilation & Running

spim -f mylab15.s 📋

Submission

Your completed mylab15.s file will be collected

Credits

Inspired by the popular word game Wordle