【问题标题】:MIPS : address out of range errorMIPS:地址超出范围错误
【发布时间】: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

任何帮助将不胜感激。

【问题讨论】:

    标签: assembly mips


    【解决方案1】:
    lbu $t1, '+'
    

    '+' 不是有效地址。你可能是说

    li $t1, '+'
    

    无论如何,请记住,任何体面的 C 编译器都会为您将 C 转换为 MIPS。

    【讨论】:

    • 谢谢,我知道它必须是这样的小东西。这是针对我正在开发的项目,因此使用 mips_gcc 编译器会破坏目的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多