Setting the rightmost bit of a division operand
-
14-11-2019 - |
Domanda
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?
Soluzione
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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow