Instruction references undefined error in MIPS/QTSPIM

5

I am triying to count all characters in an array and i had the following error:

Instruction references undefined symbol at 0x00400014 [0x00400014] 0x0c000000 jal 0x00000000 [main] ; 188: jal main

.data

 string:    .asciiz "nice work..."



  .text
 .globl main

  lw $a0,string
  jal strlength
  li $v0, 10
  syscall

   # METHOD STRLENGTH
   # Receives as first parameter the direction of the first character of string.
   # Returns the length of the string.

   strlength: li $t0, 0  #numero de caracteres
   lb $t4,string($t0)       #recorremos la cadena
   beqz $t4, fin            #si el caracter es igual a cero vamos a fin    
   addi $t0,$t0, 1      
   j strlength

   move $a0,$t0               #imprimimos numero de caracteres 
   li $v0, 1
   syscall 
   jr $ra 
assembly
mips
qtspim
asked on Stack Overflow Nov 8, 2014 by piyuyo

3 Answers

8

.globl main doesn't define the symbol, it just marks it as global if it will ever be defined. You need to add a main: label to the appropriate place, which in your case would probably be the first instruction.

answered on Stack Overflow Nov 8, 2014 by Jester
5

You should change the simulator Settings. Simulator-->Settings-->MIPS-->Exception Handler: Uncheck this option "Load Exception Handler" this way you disabling the native MIPS code and your own code works.

answered on Stack Overflow Sep 13, 2015 by JosiasF
0

I am a complete beginner to MIPS but when I was using QtSPIM this error popped up a lot. It turned out that it was because I was clicking on 'Reinitialize Simulator" every time, and that caused the error. So whenever you want to re-run a program just clear registers, dont reinitialize simulator.

answered on Stack Overflow Aug 25, 2020 by dragonejt

User contributions licensed under CC BY-SA 3.0