How to compare elements of array in mips assembly? -
i know how iterate through array in mips. can't seem figure out how compare 2 elements in same array? can point me in right direction here?
if(array[i] > array[i - 3])
i believe branch if greater comparing 2 registers how data 2 registers? thanks!
you cant iterate array... have add multiple of 4 (=> index * 4) memory address of array. can load value @ modified memory addres , compair diffrent moddified addres...
.data array: .word 1,2,3 #index's want compair i1: .word 0 i2: .word 1 .text main: lw $a0 i1 lw $a1 i2 li $t5 4 #load multiplier mul $a0 $a0 $t5 mul $a1 $a1 $t5 la $t0 array la $t1 array add $t0 $t0 $a0 add $t1 $t1 $a1 lw $t0 ($t0) lw $t1 ($t1) beq $t0 $t1 true
Comments
Post a Comment