title: Storing Matrices from console in MIPS Assembly
body: <p>I am trying to store two 3x3 matrices input by the user in MIPS so that eventually I can perform matrix multiplication. I can store the MatrixA just fine but when I try to store MatrixB I get the error </p>
  
  <pre><code>Exception occurred at PC=0x00400060
  Unaligned address in store: 0x10010009
  </code></pre>
  
  <p>I know there is a memory alignment issue but how do I fix that?</p>
  
  <p>Here is my code so far (I am using QTSpim to run it):</p>
  
  <pre><code>.data
  matrixA: .space 9
  matrixB: .space 9
  
  
  
  .text
  
  main: 
  la $a1,matrixA  #load a pointer to array into $a1
  la $a2,matrixB  #load pointer to array into $a2
  
  addi $t1,$t1,9  #size of the array(matrix in array form)
  addi $t3,$t3,9  
  
  matA_loop: 
  addi $t1,$t1,-1   #subtract 1 from $t1, save to $t1 
  li $v0,5          #load 5 into $v0 (read integer) 
  syscall           #input from user
  sw $v0,0($a1)     #store input int to array 
  addi $a1,$a1,4    #add 4 to $a1, save to $a1 
  bnez $t1,matA_loop     #if $t1 isn't zero,goto loop 
  la $a1,matrixA       #load array pointer into $a1 
  
  matB_loop: 
  addi $t3,$t3,-1   #subtract 1 from $t3, save to $t3
  li $v0,5          #load 5 into $v0 (read integer) 
  syscall           #prompt for input 
  sw $v0,0($a2)     #store input int to array 
  addi $a2,$a2,4    #add 4 to $a2, save to $a2 
  bnez $t3,matB_loop     #if $t1 isn't zero,goto loop 
  la $a2,matrixB       #load array pointer into $a1 
  
  li $v0, 10
  syscall
  </code></pre>