So I have to create an MIPS assembly program that reads 2 numbers out of 2 registers ($s0 & $s1) and calculates the number of bits that these 2 numbers differ by. And stores the result in the $s2 register. I also have to fulfill all the above with the least amount of commands possible. I have tried a few things on paper with XOR operations but I can't quite figure how to calculate the amount of different bits.
If anyone can help, you're more than welcome to. Thanks in advance
XOR the bits together and then count the number of bits in the resulting number. To do that, you can loop over each bit, check if it is set (by using a bitmask and bitshift), and then increment a counter.
I am purposefully leaving this vague as this is for you to figure out.