title: Assembly MIPS: Initializing and suming up an array
body: <p>Let's say we have an array of 10 numbers and we want to sum those numbers to a variable like this:</p>
  
  <pre><code>int arr[10]= {1, 15, 0, -3, 99, 48, -17, -9, 20, 15};
  
  sum = 0;
  
  for(i=0; i&lt;10; i++)
  
     sum = sum + arr[i];
  </code></pre>
  
  <p>When I try to "assembly mips" this, a particular line goes off:</p>
  
  <pre><code>.data
  arr: .word 1, 12, 0, -3, 99, 48, -17, -9, 20, 15
  
  .text
  .globl main
  main:
  
  add $t0, $zero, $zero   #counter i
  add $t1, $zero, $zero   #sum
  
  la  $t2, arr      #loading the address of the array to a register
  
  loop:
  slti    $t3, $t0, 10        #i&lt;10
  beq $t3, $zero, EXIT
  
  add $t1, $t1, $t2($t0)     #wrong wrong very wrong
  
  addi    $t0, $t0, 1        #i++
  j loop
  EXIT:
  
  li  $v0, 10
  syscall
  </code></pre>
  
  <p>I have a problem understanding how to express the "arr[i]" point to Assembly.</p>
  
  <p>What is the right expression for it?</p>
  
  <p>Do I have to take another registry for each number of the array?</p>