I’m having trouble with my program. My goal is to iteratethrough the array and add only the even values together. When I runthis program it hangs and I don’t know why.
.text
.globl main
main:
lui $16,0×1000
lw $17,0($16)
addiu $16, $16, 0
addiu $18, $0, 2
addiu $19, $0, 28
loop:
beq $16, $19, exit
div $17, $18
mfhi $13
beq $13, $0, even
addiu $16, $16, 4
j loop
even:
add $10, $10, $17
addiu $16, $16, 4
j loop
exit:
.data
size: .word 8
array: .word 23, -12, 45, -32, 52, -72, 8, 13
Answer
C Code to Sum up Even values in an array:
MIPS
OR
OR