在MIPS中,如何将此表达式转换为MIPS?
y = 2x+3z (x,y,z是变量)
我使用multi $t0,$s0, 2 # $s0 stores x and $s1 stores y.来显示2x。对吗?
发布于 2011-09-19 04:35:26
假设:
X在$s0中
Z在$s1中
Y将在$s2中
add $s2, $s0, $s0 # x*2 in $s2
add $t0, $s1, $s1 # z*2 in $t0
add $t0, $t0, $s1 # z*3 in $t0
add $s2, $s2, $t0 # x*2+z*3 in $s2我们实际上不进行乘法(它比简单的加法慢),正如您所看到的,我们销毁了临时寄存器$t0,但没有触及$s0/$s1
https://stackoverflow.com/questions/7464120
复制相似问题