Parrot-branches
提供:Dev Guides
オウム-枝
コードはフロー制御なしでは少し退屈です。まず、Parrotは分岐とラベルについて知っています。 ブランチopはPerlのgotoと同等です:
branch TERRY
JOHN: print "fjords\n"
branch END
MICHAEL: print " pining"
branch GRAHAM
TERRY: print "It's"
branch MICHAEL
GRAHAM: print " for the "
branch JOHN
END: end
また、レジスタにtrue値が含まれているかどうかを確認する簡単なテストを実行できます。
set I1, 12
set I2, 5
mod I3, I2, I2
if I3, REMAIND, DIVISOR
REMAIND: print "5 divides 12 with remainder "
print I3
branch DONE
DIVISOR: print "5 is an integer divisor of 12"
DONE: print "\n"
end
比較のために、Perlでは次のようになります。
$i1 = 12;
$i2 = 5;
$i3 = $i1 % $i2;
if ($i3) {
print "5 divides 12 with remainder ";
print $i3;
} else {
print "5 is an integer divisor of 12";
}
print "\n";
exit;
オウムオペレーター
eq、ne、lt、gt、le、geのすべての数値コンパレータがあります。 これらの演算子は、異なる型の引数には使用できないことに注意してください。使用している引数のタイプを伝えるために、接尾辞_iまたは_nをopに追加する必要があるかもしれませんが、アセンブラはこれを読むまでにこれを理解する必要があります。