Assembly MIPS/QTSPIM中的指令引用未定义错误

Assembly MIPS/QTSPIM中的指令引用未定义错误,assembly,mips,qtspim,Assembly,Mips,Qtspim,我正在尝试计数数组中的所有字符,但出现以下错误: 指令引用0x00400014处的未定义符号 [0x00400014]0x0000000日本航空0x00000000[main];188:日航干线 .data string: .asciiz "nice work..." .text .globl main lw $a0,string jal strlength li $v0, 10 syscall # METHOD STRLENGTH # Re

我正在尝试计数数组中的所有字符,但出现以下错误:

指令引用0x00400014处的未定义符号 [0x00400014]0x0000000日本航空0x00000000[main];188:日航干线

.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 

.globl main
不定义符号,它只是将其标记为全局符号(如果定义过)。您需要在适当的位置添加一个
main:
标签,在您的情况下,这可能是第一条指令。

您应该更改模拟器设置。模拟器-->设置-->MIPS-->异常处理程序:取消选中此选项“加载异常处理程序”,这样您就可以禁用本机MIPS代码,并且您自己的代码也可以工作。

我是MIPS的完全初学者,但当我使用QtSPIM时,经常出现此错误。事实证明,这是因为我每次都在点击“重新初始化模拟器”,这导致了错误。所以,每当你想重新运行一个程序时,只需清除寄存器,不要重新初始化模拟器