【发布时间】:2012-02-02 05:51:39
【问题描述】:
我正在尝试转这个 C 代码:
if (op == '+') {
acc += val;
}
进入 MIPS,我不知道是什么导致地址超出范围错误
#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
任何帮助将不胜感激。
【问题讨论】: