I'm very new to MIPS. Ok, so my whole program is, about a user enters 10 integers and then we store it in an array, we then calculate the min and max and then print out the unsorted array. Then we begin the bubble sort algorithm where I'm struggling at right now, im not gonna post my whole program because of its a lot, I'm only gonna post my bubble sorting algorithm.
This is my thought process of my algorithm, so first i initialize my counters and size of my array. then I begin my outer loop which is branch to endouter if i == size, then inner loop, branch to endinner if j == size, then get both of my indexes that ima compare, compare then and if my first index is greater than the second index, then swap. I'm getting an endless loop of exception for some reason, anyone helps?
#BubbleSort
li $t2, 0 #outer counter = 0 i
li $t1, 9 #size of array 0-9
li $t8, 1 #inner counter j
outer: beq $t2,$t1, endouter #branch to endouter if i < 0
inner: beq $t8,$t1, endinner #branch to endinner if j < size
li $t9, 1
sub $t9,$t8, $t9 #j - 1
lw $t4,array($t9) #load (j-1) into temp
lw $t5,array($t8) #load j into temp
blt $t4,$t5, noswap #if (j-1) < j branch to no swap
lw $t4,array($t8) #swithc (j-1) with j
lw $t5,array($t9) #swithc (j-1) with j
noswap: add $t8,$t8, 1 #increment j
j inner
endinner:
add $t2,$t2,1
li $t8, 1
j outer
endouter: