I am trying to achieve the following via MIPS assembly:
for(int i=0; i<n ; ++i){
arr2[i] = arr1[i];
}
$t2
stores the address of starting point ofarr1
and$t3
stores the starting point ofarr2
$t1
stores the valuen
upto which the loop runs.
My assembly code is as follows:
#save the value of $t2 and $t3
move $t8, $t2
move $t9, $t3
#init i=0
move $s7, $zero
copyArrayLoop: beq $s7, $t1, endCopyLoop
sw $t2, 0($t3)
addi $t2, $t2, 4
addi $t3, $t3, 4
addi $s7, $s7, 1
j copyArrayLoop
endCopyLoop: move $t2, $t8
move $t3, $t9
however, this copies the address of values stored at $t2
as it increments, and not the value in memory at address denoted by $t2
, can anyone point what's going wrong here?