Q3c: HoopsRank.s
(50) Write a MIPS program called HoopsRank.s that is similar to the C program you wrote in Homework
#3. However, Instead of reading in a file, your assembly program will read in lines of input from the
console. Each line will be read in as its own input (using spim’s syscall support for reading in inputs of
different formats). The input is a series of team stats, where each team entry is 4 input lines long. The
first line is a name to identify the team (a string with no spaces), the second line is the average number
of points the team scores per game (an int), the third line is the average number of points the team
gives up per game (another int), and the fourth line is the average rebounding differential for the team
(another int, but it could be negative) After the last team in the list, the last line of the file is the string
“DONE”. For example:
Your program should prompt the user each expected input. For example, if you’re expecting the user to
input a team name, print to console something like “Team name:’
Your program should output a number of lines equal to the number of teams, and each line is the team
name and the metric that is computed as:
[(average points scored) – (average points given up)] + (average rebounding differential).
The lines should be sorted in descending order based on this metric, and you must write your own
sorting function (you can’t just use the qsort library function). Teams with equal metrics should be
sorted alphabetically (e.g. based on the stremp function). For example:
You may assume that team names will be fewer than 63 characters.
Empty files and files of the wrong format will not be fed to your program.
IMPORTANT: There is no constraint on the number of teams, so you may not just allocate space for, say,
10 team records; you must accommodate an arbitrary number of teams. You must allocate space on the
heap for this data. Code that does not accommodate an arbitrary number of teams will be penalized
(-75% penalty)I Furthermore, you may NOT first input all names and data into the program to first find
out how many teams there are and “then* do a single dynamic allocation of heap space. Similarly, you
may not ask the user at the start how many teams will be typed. Instead, you must dynamically allocate
memory on-the-fly as you receive team names. To perform dynamic allocation in MIPS assembly, I
recommend looking here.
Note: You must follow calling conventions in this program. See “Calling convention rules” above.
Performance requirement: Automated GradeScope testing will take a while (~5-15 minutes) due to the
slowness of the simulator and the size of the instructor’s HoopsRank tests. Your HoopsRank code will
need to be able to process roughly 5000 teams in 20 minutes in the GradeScope environment, else it will
time out. This means that grossly inefficient solutions may not receive full credit (i.e., it might be too
slow to copy every name and field instead of manipulating pointers). You don’t have to go crazy to hit
this – mainly avoid the combo of bubble sort + swapping data instead of pointers
You will upload HoopsRank.s into GradeScope. The following tests cases are provided. The input for each
test comes from the file listed in the Input file column. To manually reproduce a test, each line in the
file should be typed in individually.