I'm writing a program to determine if an integer is even or odd. The program begins by asking the user for an integer and is supposed to print "Even" and "Odd" depending on what that integer is. I'm having trouble creating the If-else statement.
The statement should be, if $t2=$t0, output "Odd", else, output "Even". This is the code I have now that isn't working ($t1=1, $t2=user's integer AND'd with 1, odd_str="Odd", even_str= "Even"):
bne $t2, $t1, L1
li $v0, 4
la $a0, odd_str
syscall
L1:
li $v0, 4
la $a0, even_str
syscall
The output for an odd integer is "OddEven" and the output for an even integer is "Even". Any ideas how to fix this?
syscall, so you could factor that out. - Peter Cordes