Parrot Tutorial on Parrot Branches

code gets a little boring without flow control; for starters, parrot knows about branching and labels. the branch op is equivalent to perl's 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

it can also perform simple tests to see whether a register contains a true value:

         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

here's what that would look like in perl, for comparison:

$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;

parrot operator

we have the full range of numeric comparators: eq, ne, lt, gt, le and ge. note that you can't use these operators on arguments of disparate types; you may even need to add the suffix _i or _n to the op, to tell it what type of argument you are using, although the assembler ought to divine this for you, by the time you read this.