2012-02-02 11 views
0

私は、このCコードターンしようとしています:MIPSへMIPS:範囲エラーのうちアドレス

if (op == '+') { 
     acc += val; 
    } 

を、と私は範囲エラー

#reads user input for the op 
li $v0, 12  # system call number for operator 
syscall   # reads the integer 
sw $v0, op  # stores the user input in op 


lw $t0, op  # stores op in $t0 
lbu $t1, '+'  # stores '+' in $t1 

# "if" statement 
bne $t0, $t1, Else # branches if op is not equal to + 
lw $t2, acc  # stores acc in $t2 
lw $t3, val  # stores val in $t3 

add $t2, $t2, $t3 # adds $t2 and $t3 and stores the sum in $t2 
外のアドレスを引き起こしているかを把握することはできません

助けていただければ幸いです。

答えて

3
lbu $t1, '+' 

'+'は有効なアドレスではありません。おそらく、とにかくまともなCコンパイラがあなたのためにMIPSにCに変換することを覚えておいてください

li $t1, '+' 

を意味しました。

+0

ありがとう、私はそれがそのようなものでなければならないことを知っていました。これは、私がmips_gccコンパイラを使用して目的を破るように作業しているプロジェクトです –

関連する問題