来自 java 的 MIPS 翻译
MIPS translation from java
我正在使用 MIPS 制作一个递归迷宫求解器程序,我正在尝试实现我们教授给我们的算法。但是,我坚持如何实施
boolean p = solveMaze(r - 1, c, r, c);
当我在 MIPS 中创建程序时。基本上,我如何将这样的 java 布尔表达式转换为 MIPS。
在汇编中,布尔值通常用整数表示。还使用寄存器函数 return 值。本质上,该程序看起来类似于此
...
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
我正在使用 MIPS 制作一个递归迷宫求解器程序,我正在尝试实现我们教授给我们的算法。但是,我坚持如何实施
boolean p = solveMaze(r - 1, c, r, c);
当我在 MIPS 中创建程序时。基本上,我如何将这样的 java 布尔表达式转换为 MIPS。
在汇编中,布尔值通常用整数表示。还使用寄存器函数 return 值。本质上,该程序看起来类似于此
...
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