2 # Copyright (C) 2005-2009, Parrot Foundation.
7 examples/shootout/mandelbrot.pir - Print the Mandelbrot set
11 % ./parrot examples/shootout/mandelbrot.pir -R jit 600 > out.pbm
15 This outputs a pbm file of the Mandelbrot set. Defaults to 200x200.
17 Translated from C code by Greg Buchholz into PIR
18 by Peter Baylies <pbaylies@gmail.com>.
21 The Great Computer Language Shootout
22 http://shootout.alioth.debian.org/
28 # int w, h, x, y, bit_num = 0;
32 # double Zr, Zi, Cr, Ci, Tr, Ti;
33 .local int w, h, x, y, bit_num, byte_acc, i, iter
34 .local num limit, Zr, Zi, Cr, Ci, Tr, Ti
40 # slight optimization here -- nothing a decent C compiler wouldn't already do :)
44 if argc <= 1 goto noarg
50 # printf("P4\n%d %d\n",w,h);
63 # Cr = (2*(double)x/w - 1.5);
68 # Ci=(2*(double)y/h - 1);
76 # Tr = Zr*Zr - Zi*Zi + Cr;
89 # if (Zr*Zr+Zi*Zi > limit*limit) break;
93 if $N1 > limit goto IBRK
95 if i < iter goto IREDO
98 if $N1 <= limit goto SLA
103 if bit_num != 8 goto NTST1
104 PRINT: chr $S1, byte_acc
112 if x != $I1 goto NTSTE
131 # vim: expandtab shiftwidth=4 ft=pir: