Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in MIPS assembly language that takes a set of signed 32 bit inte

ID: 670515 • Letter: W

Question

Write a program in MIPS assembly language that takes a set of signed 32 bit integers (words) as the input and classifies them into odd and even numbers. Basically just ask the user to input like 5-7 numbers and then do some modular math or however you do it in MIPS to figure out the even and odd numbers and then print them out like so:

Enter Numbers:

//code

//at the end print output

Even Numbers:

Odd Numbers:

If the user enters 9999 thats when the code begins. so enter some numbers and then 9999 and then the program should sort them even and odd

Explanation / Answer

#program to print odd and even numbers
Array:.word 20, 429, 996, 532, 764, 198, 168, 981, 921, 886
.word 864, 215, 581, 151, 435, 128, 276, 336, 790, 825

str: .asciiz "The number is even"
str1: .asciiz "The number is odd"
Next: .word 00
# $1 = array index , $3 = curent element
EvenOdd: addi $1, $0, Array # set memory base
addi $2, $0, Next # load address


Loop: lw $3, 0($1) # loading current element
andi $8, $3, 1 # mask all but LSB and place in $8
beq $8, $0, Even # If $3 is even, add to even sum and count
la $5, str1 #loading string to print
syscall
lw $5, $3 # else printing odd number
syscall
j Continue # and continue with end of loop

Even: la $4, str
syscall
lw $4, $3 # $3 is even...so printing
syscall

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote