📅  最后修改于: 2020-11-03 16:07:14             🧑  作者: Mango
没有流控制,代码会有些无聊。对于初学者,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
它还可以执行简单的测试来查看寄存器是否包含真实值:
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,以告诉您所使用的参数类型,尽管在您阅读本文时,汇编程序应为您神清。