SPIMシミュレータを使用してMIPSを開始しました。誰かが私がこのステートメントを変換するのを手伝ってもらえますか?
if(as>47 && as<58) function();
else continue;
よろしくお願いします。:)
私のMIPSは少し錆びているので、微調整なしでは機能しない場合は事前にお詫びしますが、これにより、何をしようとしているのかがよくわかるはずです。
(これが機能しない場合は、投稿を編集できるようにお知らせください)
# Assume 'as' is in $s0
li $t2, 1 # $t2 = 1
slti $t0, $s0, 58 # $t0 = $s0 < 58
addi $t1, $s0, 1 # $t1 = $s0 + 1
slti $t1, 47, $t1 # $t1 = 47 < $t1($s0 + 1) (sgti does not exist)
and $t0, $t0, $t1 # $t0 = $t0 && $t1
bne $t0, $t2, cont # if ($t0 != $t2) goto cont
function: # Label is optional.
# If both conditions are true, the bne won't branch, so we will
# fall through to function: and run whatever code it has.
# otherwise, we jump to cont: and all the func code is skipped.
# ...
cont: # continue;
# ...
現在、function()は実際には関数ではないことに注意してください。jal function
ただし、そのブロックを別の場所に配置することもできます。これは、MIPS命令セットの優れたリファレンスです。
MIPSの秘訣は、より大きい命令がないため、反対の命令を使用する必要があるということです。
>の反対は<ではなく<=であることに注意してください。