0x00400018处的MIPS / MARS运行时异常:地址超出范围0x00000000

时间:2015-09-23 19:29:55

标签: runtime mips mars-simulator

我试图在MARS中运行一些代码,但是我遇到了运行时错误

错误发生在第9行

lb  $t1, ($t0)

我的代码是:

MAIN:   addi    $sp, $sp, -4  
sw  $ra, ($sp)  
add     $t6, $0, 0x30 # '0'
add     $t7, $0, 0x39 # '9'
add $s0, $0, $0
add $t0, $a0, $0
LOOP:
    lb  $t1, ($t0)
    slt $t2, $t1, $t6
    bne $t2, $0, DONE 
    slt     $t2, $t7, $t1 
    bne $t2, $0, DONE
    sub $t1, $t1, $t6
    beq     $s0, $0, FIRST
    mul $s0, $s0, 10

FIRST:
    add     $s0, $s0, $t1
    addi    $t0, $t0, 1
    j LOOP

DONE:
    add $v0, $s0, $0
    lw  $ra, ($sp)
    addi    $sp, $sp, 4
    jr  $ra

我对mips相当新,所以我会喜欢explonation发生什么,或者只是语法错误?

0 个答案:

没有答案