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

piy*_*uyo 4 assembly mips qtspim

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

指令引用0x00400014处的未定义符号[0x00400014] 0x0c000000 jal 0x00000000 [main]; 188:jal主要

.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 
Run Code Online (Sandbox Code Playgroud)

Jes*_*ter 7

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


小智 5

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