title: MIPS program, error address out of bounds
body: <p>I'm trying to solve a small assignment question using MARS, but I keep getting this error. Is there something that I did wrong?</p>
  
  <p>I'm getting the error at linenum 11: which is lw $t0, 0</p>
  
  <p>Below is the code of my program.</p>
  
  <pre><code>.data
  
  SOURCE: .word 0x0100
  DEST: .word 0x0110
  
  
  
  
  .text
  
  lw $t0, 0
  lw $t4 , -1 
  lw $t5 , 0
  lw $t6, 20
  lw $t7, 32
  
  VERY_START:
  
  beq $t6,$zero,EXIT
  addi $t6,$t6,-1
  lw $t7,32
  
   la $t1,SOURCE
  li $t2,1
  li $s1,2
  
  
  START:
  
  and $t3, $t2 , $t1
  
  beq $t4,-1,FIRST_LOOP
  
  
  bne $t4,$t3,STORE
  #bne is branch if not equal to.
  
  add $t5 , $t5 , 1
  
  
  addi $t7, $t7 , -1
  
  beq $t7, $zero, VERY_START
  
  # So we jump to the very start if we have 32 bits done.
  
  
  
  sll  $t2, $t2 , 1
  
  j START
  
  STORE:
  
  
  
  sb $t5,DEST($t2)
  #dest needs to be defined (It is implicit according to the question)
  # after storing , we need to increment $t0 so that we can store the next element a byte away from this one. so 
  add $t0 , $t0 , 2
  
  
  
  lw $t5,1
  
  addi $t7, $t7 , -1
  
  beq $t7, $zero, VERY_START
  
  # So we jump to the very start if we have 32 bits done.
  
  
  
  sll  $t2, $t2 , 1
  
  j START
  
  FIRST_LOOP:
  # we populate t4 here
  move $t4,$t3
  j START
  
  
  EXIT:
  #we find the number of counts by simply dividing the current t0 with 2
  
  div $t0, $s1
  mflo $t0
  # we move the quotient to t0..
  
  
  move $a0,$t0
  li $v0, 1
  syscall
  </code></pre>