invalid program counter value: 0

前端 未结 3 1312
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 04:44

I\'m currently working with assembly language under the MIPS processor. I\'m currently using MARS simulator and for reasons unknown I get the following error message after every

3条回答
  •  面向向阳花
    2021-01-21 05:33

    I am new to MIPS and I just had this problem. This is what I had:

        .data
    
        .text
    
    swap:
        # do stuff
        jr  $ra
    
    main:
        # do stuff
        jal swap
        li  $v0,10
        syscall
    

    I fixed it by changing it to this:

        .data
    
        .text
    main:
        # do stuff
        jal swap
        li  $v0,10
        syscall
    
    swap:
        # do stuff
        jr  $ra
    

    Notice I moved main to be before swap. I mistakenly assumed that main was a reserved label. And that it would automatically jump straight to main first. But apparently that isn't the case because it was hitting my jr $ra instruction before I got to call jal swap in main.

    Anyway, I hope this helps.

提交回复
热议问题