Question

I am using MARS MIPS simulator to simulate the division in assembly codes. During the shifting process, how do I set the rightmost bit of the quotient to 1 and 0? I used ori $t2,$t2,1 to set 1 and andi$t2,$t2,-2 to set 0, is that the way I should do?

Was it helpful?

Solution

Yes, this is a perfectly valid way. In one instruction (simple bit wise operation), you obtained what most people try to do using some shady arithmetic and possible branching instructions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top