I just started learning MIPS 32 and try to run this code, it runs smoothly on MARS MIPS simulator but when I saved it into (.asm) file and tried to run on QtSpim, the console pops out with the message "Hello World" but an Error: "Attempt to execute non-instruction at 0x0040000c" also shows up, did I missed something or is any part incorrect?
I have also tried to uncheck the exception handler but to no avail.
Here is the code:
.data
Message: .asciiz "Hello World"
.text
li $v0, 4
la $a0, Message
syscall
According to spim point of view, there are two problems with your program
spim expects a main and none is declared in your program.
spim continues executing the "program" after the last instruction. There should be a syscall 10 at the end to stop excution.
So, a working version of your program for spim is
.data
Message: .asciiz "Hello World"
.text
main: # start of program
li $v0, 4
la $a0, Message
syscall
exit:
li $v0, 10 # syscall 10 terminates program
syscall # and exits
Indeed, spim is a bit touchy and I would advice you to use mars if it is possible. Besides that, it is a good practise to always add a main and an exit in your programs.