title: Input and output array elements in MIPS
body: <p>Here is my MIPS code. It is supposed to input 10 integers in array and then output them. I can input integers but after entering 10 integers it doesn't output any array element.</p>
  
  <pre><code>.data
  arr: .space 40
  
  .text
  .globl main
  main:
      la $t0, arr #copying array address into $t0
  
      iterateForInput:
          blt $t4, 9, forLoopInput
  
      sub $t0, $t0, 40
  
      iterateForOutput:
          blt $t4, 9, forLoopOutput
  
      li $v0, 10
      syscall
  
  forLoopInput:
      li $v0, 5   #input integer
      syscall
      move $t1, $v0   #moving integer into $t1
      sw $t1, ($t0)   #storing integer at array address
      add $t0, $t0, 4
      add $t4, $t4, 1
      b iterateForInput
  
  forLoopOutput:
      lw $t6, ($t0)
      li $v0, 1
      move $a0, $t6
      syscall
      add $t0, $t0, 4
      add $t4, $t4, 1
      b iterateForOutput
  </code></pre>