来自java的MIPS翻译

时间:2016-11-14 23:45:19

标签: recursion mips maze

我正致力于在MIPS中制作递归迷宫求解器程序,并且我试图实现我们教授给我们的算法。但是,我仍然坚持如何实施

boolean p = solveMaze(r - 1, c, r, c);

当我在MIPS中创建程序时。基本上,我如何将这样的java布尔表达式转换为MIPS。

1 个答案:

答案 0 :(得分:0)

在汇编中,布尔值通常用整数表示。函数也使用寄存器返回值。基本上该程序看起来与此类似

...
main:
    # store parameters in registers $a0 to $a3
    jal solveMaze
    mov $t0, $v0
    li $v0, 1
    syscall    # prints 1 or 0 depending on what was returned

solveMaze: # $a0 = r - 1, $a1 = c, $a2 = r, $a3 = c
    ...    # Do what needs to be done here
    li $v0, 1  # $v0 contains 1 which means true, change to 0 for false
    jr $ra     # return to the caller of the function