title: MIPS: Target of jump differs in high-order 4 bits from instruction pc 0x400014
body: <p>Alright, so I've started writing MIPS code to multiply two arrays. I wanted to put what I had so far into QtSpim to see if values would change as I was expecting them to.</p>
  
  <p>However, when I try to load my file into QtSpim I am getting this error:<br>
  <code>Target of jump differs in high-order 4 bits from instruction pc 0x400014</code></p>
  
  <p>Do you see where I'm going wrong, or have any good ideas for debugging? I'm not sure what or where the problem is.</p>
  
  <p>Thanks.</p>
  
  <p><em><strong>EDIT</em>:</strong> This works:</p>
  
  <pre><code>main:
      la      $a2, array1
      la      $a3, array2
      li  $a1, 5
      li  $v0, 1
      add     $a0, $a1, $0
      syscall
  
      lw  $a0, 0($a2)
      syscall
  
      lw  $a0, 0($a3)
      syscall
  
      li  $v0, 10
      syscall
  .data
  array1: .word 10, 10, 10, 10, 5
  array2: .word -10, -10, 10, 10, 5
  </code></pre>
  
  <p>Full code:</p>
  
  <pre><code>.data
  array1: .word 10, 10, 10, 10, 5
  array2: .word -10, -10, 10, 10, 5
  
  main:
  
  li $a2, 5
  addiu $15, $a2, 1
  la $a0, array1
  la $a1, array2
  j MAC
  
  MAC:
  
  addiu $sp, $sp, -4
  sw $ra, 4($sp)
  li $v1, 0
  li $s0, 0
  
  loopInMAC:
  
  beq $s0, $15, main2
  j mult1
  add $v1, $v1, $v0
  addiu $s0, $s0, 1
  j loopInMAC
  
  mult1:
  
  lw $s1, 0($a0)
  lw $s2, 0($a1)
  slt $s3, $s1, 0
  slt $s4, $s2, 0
  addiu $sp, $sp, -4
  sw $ra 0($sp)
  bne $s3, 1, skip1
  sub $s1, $0, $s1
  
  skip1:
  
  bne $s4, 1, skip2
  sub $s2, $0, $s2
  
  skip2:
  
  li $v0, 0
  
  loopInMult:
  
  beq $s1, $0, skip3
  andi $t0, $s1, 1
  beq $t0, $0, skipAdd
  add $v0, $v0, $s2
  
  skipAdd:
  
  sll $s2, $s2, 1
  srl $s1, $s1, 1
  j loopInMult
  
  skip3:
  
  beq $s1, $s2, equalSign
  sub $v0, $0, $v0
  
  equalSign:
  jr $ra
  </code></pre>