Im writing a project in mips, and i load a bunch of inputs into memory. when i read them back out there in the same order except for the zero which ALWAYS get moved to the end of the array. I literally load the values straight into memory after reading them so i dont see how its possible.
boardInput:
add $t0, $zero, $zero
la $s3, array #Array for values to be stored
add $t1, $zero, $zero #Has zero been added yet?
add $t2, $zero, $zero #counter for loop
loop:
beq $t2, $s1, boardInputDone
addi $t2, $t2, 1 #counter for loop
li $v0, 5 #Get the response
syscall
sw $v0, 0($s3)
add $s2, $zero, $v0
beq $s2, $zero, zeroFound
addi $s3, $s3, 4
j loop
zeroFound:
addi $t3, $zero, 1
beq $t3, $t1, endError1
add $t1, $zero, $t3
j loop
boardInputDone:
beq $t1, $zero, endError2
j printMemory
**** user input : 15
**** user input : 0
**** user input : -150
**** user input : 52
15 -150 52 0