【问题标题】:Instruction references undefined error in MIPS/QTSPIM指令引用 MIPS/QTSPIM 中的未定义错误
【发布时间】:2014-11-08 00:55:05
【问题描述】:

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

指令引用了 0x00400014 处的未定义符号 [0x00400014] 0x0c000000 日航 0x00000000 [主] ;第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 

【问题讨论】:

    标签: assembly mips qtspim


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您应该更改模拟器设置。 Simulator-->Settings-->MIPS-->Exception Handler:取消选中“Load Exception Handler”这个选项,这样你就禁用了本地 MIPS 代码,你自己的代码就可以工作了。

      【讨论】:

        【解决方案3】:

        我是 MIPS 的完全初学者,但是当我使用 QtSPIM 时,这个错误弹出了很多。原来是因为我每次都点击“Reinitialize Simulator”,才导致报错。所以当你想重新运行程序时,只需清除寄存器,不要重新初始化模拟器。

        【讨论】:

          猜你喜欢
          • 2016-08-31
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多