Friday, April 20, 2012

In MIPS, how do I divide register contents by two?

Let's say I have $t0, and I'd like to divide its integer contents by two, and store it in $t1.



My gut says: srl $t1, $t0, 2



... but wouldn't that be a problem if... say... the right-most bit was 1? Or does it all come out in the wash because the right-most bit (if positive) makes $t0 an odd number, which becomes even when divided?



Teach me, O wise ones...





No comments:

Post a Comment