Task

Test whether an integer is even or odd.

There is more than one way to solve this task:

 Use the even and odd predicates, if the language provides them.
 Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd.
 Divide i by 2. The remainder equals 0 iff i is even. The remainder equals +1 or -1 iff i is odd.
 Use modular congruences:
 i ≡ 0 (mod 2) iff i is even.
 i ≡ 1 (mod 2) iff i is odd.


 
.data
	even_str: .asciiz "Even"
	odd_str: .asciiz "Odd"
 
.text
	#set syscall to get integer from user
	li $v0,5
	syscall
 
	#perform bitwise AND and store in $a0
	and $a0,$v0,1
 
	#set syscall to print dytomh
	li $v0,4
 
	#jump to odd if the result of the AND operation
	beq $a0,1,odd
even:	
	#load even_str message, and print	
	la $a0,even_str
	syscall
 
	#exit program
	li $v0,10
	syscall
 
odd:
	#load odd_str message, and print
	la $a0,odd_str
	syscall
 
	#exit program
	li $v0,10
	syscall
 