hi there, the Examples page on www.parrotcode.org states this about subroutines:
The first five registers (I0-I4, S0-S4, P0-P4, N0-N4) are scratch and do not have to be preserved by the callee. this seems to be false for *recursive* subroutines. this is my PASM code fibo.pasm (it calculates the fibonacci number of 32): set I0, 32 bsr FIBO print I0 print "\n" end FIBO: lt I0, 2, FIBO_ONE set I1, I0 set I2, I1 dec I2, 2 set I0, I2 save I1 save I2 save I3 bsr FIBO restore I3 restore I2 restore I1 set I1, I0 inc I2 set I0, I2 save I1 save I2 save I3 bsr FIBO restore I3 restore I2 restore I1 add I0, I0, I1 branch FIBO_END FIBO_ONE: set I0, 1 FIBO_END: ret for this code to work correctly, I need to save and restore I1, I2, I3 on each recursive call. am I missing something or is just something that needs to be documented? and now for timings: I tested the new parrot (checked out some minutes ago) with JIT v2 enabled and these are the results: CPU MEM parrot fibo.pbc 8.74 736 parrot -j fibo.pbc 6.13 772 just for reference, these are the times from other languages: CPU MEM Visual C++ (6.0) 0.13 452 gcc (2.95.3) 0.20 1344 C# (7.00.9466) 0.24 3888 java (1.4.0-b92) 0.58 4972 python (2.1.1) 14.72 2128 perl (5.6.1) 21.89 1416 ruby (1.6.5) 29.71 1912 note that comparison with parrot is not really fair because all the other programs accept the number (32 in our case) from the command line. cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print;