> If you really want a comparison, here's one. Take this loop:
> 
>      i = 0;
>      while (i < 1000) {
>        i = i + 7;
>      }
> 
> with the ops executed in the loop marked with pipes. The corresponding 
> parrot code would be:
> 
>         getaddr P0, i
>         store   P0, 0
>         store   I0, 1000
> foo: | branchgt end, P0, I0
>       | add P0, P0, 7
>       | jump foo

I think dan gave a straight forward translation, since it does not really
use the int register. The optimized code will be faster.

        store i1, 0;
        store i2, 1000;
        jump L2;
L1:
        add i1, 7 => i1;
L2:
        branchlt i1, i2 => L1;
        getaddr i => P0;
        store i1 => P0;

Howerver, I like to point out one hidden overhead of register opcode is 
decoding the parameter. The add instrction of stack machine does not have
args, but for register machine, it has 3 arguments.

Hong

Reply via email to