0

I just start to learning mips assembly programming and use QtSpim emulator. The example code is copied from a tutorial. But when loaded using QtSpim, it complains following error:

spim: (parser) syntax error on line 6 of file /home/k/Desktop/work/asm/h3.asm
   la $t0, value

The exmple code:

     1  # add two numbers
     2  .text
     3  .globl main
     4  
     5  main:
     6      la $t0, value
     7      lw $t1, 0($t0)
     8      lw $t2, 4($t0)
     9      add $t3, $t1, $t2
    10      sw $t3, 8($t0)
    11  
    12  .data
    13  value: .word 10, 20, 0
    14  
longbowk
  • 219
  • 5
  • 14
  • When I uncheck the option "Bare Machine" in Simulator/Settings. The syntax error disappeared, but click the start button on the top panel, it poped up a Error window: Attempt to execute non-instructon at 0x0040003c. – longbowk Aug 18 '16 at 03:58
  • The non-instruction error is maybe from executing garbage following main, because there's no return instruction to stop execution from falling out the bottom of main. – Peter Cordes Aug 18 '16 at 04:18
  • @PeterCordes You are right, I missed the return instruction. The QtSpim simulator has delay in refreshing registers. Now I turn to the console version. – longbowk Aug 18 '16 at 06:41
  • I'd recommend adding `li $v0,10`, `syscall` after line 10. Also, you may have better luck with the `mars` simulator. I've used `spim`, `QtSpim`, and `mars`. I prefer `mars` where possible. See: http://courses.missouristate.edu/KenVollmar/mars/ – Craig Estey Aug 18 '16 at 17:48
  • 2
    Regarding the original syntax error, `la` is a pseudo-instruction (i.e. it doesn't actually exist in the MIPS instruction set - the assembler converts it into one or more actual instructions, e.g. a `lui`/`ori` pair). – Michael Aug 21 '16 at 12:02

0 Answers0