0
votes

I am currently using SPIM (QTSpim) to learn about MIPS. I had a few questions regarding the SPIM commands and how they work.

1) As far as I know, MIPS usually uses 16 bits to display values, but why do the registers in QTSpim only have 8 bits?

2) For register $11(t3), the original value was 10. After the machine performs a [sra $11, $11, 2] instruction, the value changes from 10 to 4. How does this happen? How are 2 positions shifted right when 10 is only 2 bits?

Thank you.

1
which base are you taling about? decimal 10 is 1010 in binary which has 4 bits - phuclv
@LưuVĩnhPhúc That's actually part of the question I was asking, sorry if it wasn't clear. It seems that QTSpim uses hexadecimal. But I'm not sure why [sra $11, $11, 2] would change 10 to 4, even if it's in binary. If it's in binary, shouldn't the result be 0010? - Sean

1 Answers

1
votes

1) Not sure where you got that idea. QtSpim simulates a MIPS32-based machine, so the general-purpose registers are 32-bit.

2) 10 hexadecimal is 10000 binary. Shift that right by two and you get 100 binary, which is 4 decimal. You can also think of it as 16 decimal divided by 4, since sra by N bits is a (signed) division by 2^N.