In this lab, you will learn how to implement subroutines and manage data on the stack.
Read chapter 5 from Introduction To MIPS Assembly Language Programming.
Specification This program will display a string and prompt the user to type the same string in a given time limit. It will check if this string is identical to the given one and whether the user made the time limit. If the user types in the prompt incorrectly or does not finish the prompt in the given time limit, the game is over.
String Prompts The strings that will be given to the user are contained in the .data segment defined in the Lab5_test.asm file. The address of these strings will be part of the arguments to your subroutines. When testing for string correctness, you will be checking punctuation.
Timing To monitor timing, you will be using syscall 30. This syscall gets the current system time in milliseconds as a 64 bit value. It stores the upper 32 bits in $a1 and the lower 32 bits in $a0.
The Stack The stack is a data structure that we will be using in this lab. This will primarily be used the handle the preservation of certain register values at the start of a subroutine so that they can be restored at the end of a subroutine. The most notable use of this will be preserving the jump and link return address, $ra, so that you can navigate out of nested subroutines. In addition, the values in registers $s0 - $s7 must be preserved across subroutine calls.
Subroutines Lab5.asm will contain the subroutines to display and check the string as well as keep track of the time limit. You must implement all of the subroutines listed, and you may create more of your own subroutines. If you plan on using any of the saved registers, $s0 - $s7, you must save these registers appropriately on the stack (push at the beginning of your subroutine, then pop at the end of the subroutine).
Nested Subroutines Two of the following subroutines will be called from within another subroutine.
Specifically, compare_strings will be called from inside of check_user_input_string, and compare_chars will be called from inside of compare_strings. In order to properly execute these nested subroutines, you must properly use the stack to handle the return address register, $ra.
# input: $a0 - first char to compare (contained in the least significant byte) # $a1 - second char to compare (contained in the least significant byte) #
# output: $v0 - comparison result (1 == chars the same, 0 == chars not the same) #
Your program must work properly with the testing program provided (on Canvas).
Output Your output format should appear as follows where the prompt is displayed next to “Type Prompt:” and the user inputs their prompt beneath this.
Diagram.pdf
This file will contain a block diagram or flowchart of how the different components of your code work together.
Lab5.asm
This file contains your assembly code. See the Code Documentation section from previous labs for instructions on proper code formatting. Pseudocode is not required for this lab, though you may include it after the header comment. You must include a block comment on register usage as indicated in previous labs.