I will not give the code here because I do not have the MIPS compiler, and you do not want to mislead you, but the nuts and bolts of what you need to do is read each character from line to register 1 at a time, then scroll through the remaining characters by checking / comparing them to see if they match the current character value. If so, add another register, which is a pair counter. Depending on what you need to return, you can either immediately return to the match or set up a different register to save the best character and the best match. Honestly, for something like this, you might need to write it in a low-level language such as C to start by understanding where the loops and locals are, and then transform it.
source share