mipsqtspim

QtSpim Error "Attempt to execute non-instruction at 0x0040000c"


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?

Error screnshot

I have also tried to uncheck the exception handler but to no avail.


Solution

  • According to spim point of view, there are two problems with your program

    1. spim expects a main and none is declared in your program.

    2. 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.