我正在尝试在 Mips 中显示“Hello World”(来自 Internet 上的示例)并查看它是如何工作的,但最终出现错误。我首先遇到以下错误:“spim: (parser) Label is defined for the第二次出现在文件 C:Program Files (x86) main: # Execution started at label "main" " 的第 6 行 ^ 为了修复它,我重新初始化并重新加载。然后我运行 Qtspim,最终出现以下错误:“指令在 0x00400028/Notepad++/test.asm [0x00400028] 0x3c010000 lui $1, 0 [Greetings] 处引用未定义符号;8:la $a0, Greetings # load address of string打印成 $a0
有人可以解释导致第一个和第二个错误的原因吗?我只是想测试我在网上找到的代码,并在尝试分配之前了解 Qtspim 的工作原理。我在 Windows 08 上使用 Notepad++。非常感谢您的帮助。下面是代码。
# Program: Hello, World!
.data # data declaration section; specifies values to be stored
# in memory and labels whereby the values are accessed
Greeting: .asciiz "\nHello, World!\n"
.text # Start of code section
main: # Execution begins at label "main"
li $v0, 4 # system call code for printing string = 4
la $a0, Greetings # load address of string to be printed into $a0
syscall # call operating system to perform operation;
# $v0 specifies the system function called;
# syscall takes $v0 (and opt arguments)
#This illustrates the basic structure of an assembly language program.