File: random.pasm

package info (click to toggle)
parrot 2.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 23,156 kB
  • ctags: 14,972
  • sloc: perl: 96,188; ansic: 88,708; yacc: 4,923; lex: 4,254; lisp: 1,163; cpp: 746; python: 541; ruby: 351; makefile: 184; sh: 146; cs: 49; asm: 30
file content (55 lines) | stat: -rw-r--r-- 994 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!./parrot -R jit
# Copyright (C) 2005-2009, Parrot Foundation.
# $Id$
#
# random.pasm N         (N = 900000 for shootout)
# by Joshua Isom

# I0 = last
# I1 is the counter for the loop
# N2 is the argument for gen_random
# N3 is the return from gen_random
main:
    new P10, 'ResizableIntegerArray'
    get_params "0", P0
    elements I0, P0
    eq I0, 2, hasargs
    set I1, 900000
    branch argsdone
hasargs:
    set S0, P0[1]
    set I1, S0
argsdone:
    set I0, 42
    unless I1, ex
    set N2, 100.0
while_1:
    local_branch P10, gen_random
    dec I1
    if I1, while_1
    new P0, 'FixedFloatArray'
    set P0, 1
    set P0[0], N3
    sprintf S0, "%.9f\n", P0
    print S0
ex:
    end

.macro_const IM 139968
.macro_const IA 3877
.macro_const IC 29573

gen_random:
    mul I0, .IA
    add I0, .IC
    mod I0, .IM
    set N1, I0
    mul N3, N2, N1
    div N3, .IM
    local_return P10

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: