How to find even the odd ones in an MIPS assembly using integer registers

How to find out if an input is even or odd in MIPS? I am trying to find the use of 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 

But this program even shows odd numbers, since this is because the result in decimal is 0.3. How can I solve this problem?

+1
source share
1 answer

You need and number you want to check with 0x01 .

So you use and in mips: and $d, $s, $t

If the value in the target register is 1, then it is even clearer.

+2
source

Source: https://habr.com/ru/post/1447251/


All Articles