Mips:“Hello World”遇到错误

时间:2013-02-25 09:14:40

标签: assembly mips spim qtspim

我正在努力展示" Hello World" (来自互联网上的一个例子)在Mips中查看它是如何工作的,但我最终得到了错误。我首先遇到以下错误:" spim :( parser)标签在第6行第2次定义文件C:程序文件(x86) main:#执行从标签" main"开始"  ^ 要修复它,我重新初始化并重新加载。然后我运行Qtspim并最终得到以下错误:"指令引用0x00400028 / Notepad ++ / test.asm中的未定义符号 [0x00400028] 0x3c010000 lui $ 1,0 [问候]; 8:la $ a0,问候#加载要打印到$ 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.

1 个答案:

答案 0 :(得分:0)

您标记了字符串Greeting,但在代码中将其称为Greetings,无法识别。

此外,您似乎永远不会在jr $ra之后从您的函数(例如syscall或类似函数)返回,因此在未定义的数据上继续执行。