如何使用整数寄存器找偶奇在MIPS汇编 [英] How to find even odd in MIPS assembly using integer registers
本文介绍了如何使用整数寄存器找偶奇在MIPS汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能找到输入是偶数或奇数的MIPS?我试图找出使用整数寄存器,但我的计划是行不通的。这里是code:
How can I find whether the input is even or odd in MIPS? I am trying to find out using integer registers, but my program is not working. Here is the code:
li $s1,2
div $s0,$s1
mfhi $t0
xor $t1,$t0,$0
beq $t1,0,Even
j Odd
但这个方案表明,即使奇数,因为即使这是因为结果是像0.3小数。我怎样才能解决这个问题呢?
But this program shows even odd numbers as even this is because the result is in decimal like 0.3 . How can I solve this issue?
推荐答案
您需要和
要检查与数0×01
。
这是你如何使用和
在MIPS:和$ D,$ S,$ T
This is how you use and
in mips: and $d, $s, $t
如果在目标寄存器中的值是1,那么它是别的奇偶。
If the value in target register is 1 then it is odd else even.
这篇关于如何使用整数寄存器找偶奇在MIPS汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文