Least significant bit mips

寵の児 提交于 2021-02-08 06:35:52

问题


How can i change least significant bit in a register in Mips?
In another post How to get LSB bit in MIPS? it saws how to get it but i want to change it.


回答1:


The following one line should do it:

xori $t0, $s0, 1

Explained: the contents in $s0 contains zeros and ones, while the immediate value has zeros and a one in the LSB. Whenever the LSB is 0, it is xored with 1 and outputs a 1. Whenever it is 1, it is xored with 1 and outputs a 0. The remaining bits will output a 1 if they are 1 and a 0 if they are 0 because they are being xored with 0, thus preserving their state.




回答2:


You can use this code:

li $t3,1
xor $t0,$s0,$t3


来源:https://stackoverflow.com/questions/23531623/least-significant-bit-mips

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!