Convert from Java to MIPS

You’re missing a couple of loads, and your store is incorrect:

sll  $t3, $t1, 2     //get the offset (i*4)
add  $t4, $t3, $s2   //t4 is the address for save[i]
lw   $t5,($t4)       //t5 = save[i]
beq  $t5, $t2, exit  //check the while condition
add  $t5, $t3, $s3   //t5 is the address for v[i]
lw   $t5,($t5)       //t5 = v[i]
sw   $t5, ($t4)      //save[i] = v[i]
addi $t1, 2          //inc i

Leave a Comment