I am writing a program in Mips that is given this asciiz string: .asciiz “7A23232”. Each character in the string corresponds to a card from a deck of cards. I need to check for two of a kinds and three of a kinds. How do I check each individual character in the String. I’m looking for something similar to Java’s charAt().
Share
Not going to give any code away here because I don’t have a MIPS compiler handy and don’t want to mislead you, but the nuts and bolts of what you need to do is to read each character from the string into a register 1 at a time, then loop through the remaining characters checking/comparing to see if they match the current character’s value. If so, increment another register that is the pair counter. Depending on what you need to return, you can either return immediately up a match, or setup another register to store best character and best match amount. Honestly, for something like this, you might want to write it in a low level language like C to start with just to get a feel for where the loops and locals are, then convert that.