0
votes

I am trying to display "Hello World" (from an example found on internet) in Mips and see how it works, but I end up with errors.I first had the following error :"spim: (parser) Label is defined for the second time on line 6 of file C:Program Files (x86) main: # Execution begins at label "main" " ^ To fix it, I reinitialized and reloaded. Then I run Qtspim and I end up with the following error: "Instruction references undefined symbol at 0x00400028/Notepad++/test.asm [0x00400028] 0x3c010000 lui $1, 0 [Greetings] ;8:la $a0, Greetings # load address of string to be printed into $a0

Can someone please explain what causes the first and second error? I am just trying to test the code that I found online and understand how Qtspim works before I try my assignment. I am using Notepad++ on Windows 08. Your help will be very appreciated. Bellow is the code.

# 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
I don't know what is the first error, but the second means there's no label called Greetings. I understand you meant Greeting.m0skit0
Oups!!!! I did not see that one! I fixed it, but now, I have another error: "Attempt to execute non-instruction at 0x00400030". I know it is related to memory location. But I can't figure out why I have that new error.T4000
If you keep changing the question, we will never end.m0skit0
Possible duplicate of Getting the error: "Instruction references undefined symbol ... main" in QTSpim. Oops, that's not right. There is no .globl, but the problem being asked about is different spellings of another label. It's actually just a typo bug.Peter Cordes

1 Answers

1
votes

You labeled the string Greeting but referred to it as Greetings in your code, which cannot be recognized.

Also, it seems that you never return from your function (e.g. jr $ra or similar) after the syscallso the execution continues on undefined data.