File:  [gforth] / gforth / sieve.fs
Revision 1.2: download - view: text, annotated - select for diffs
Wed Aug 31 19:42:52 1994 UTC (27 years, 1 month ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Added options to allow good register scheduling on i386
added blocks

    1: #! /usr/stud/paysan/bin/forth
    2: 
    3: DECIMAL
    4: : SECS TIME&DATE  SWAP 60 * + SWAP 3600 * +  NIP NIP NIP ;
    5: CREATE FLAGS 8190 ALLOT
    6: FLAGS 8190 + CONSTANT EFLAG
    7: 
    8: : PRIMES  ( -- n )  FLAGS 8190 1 FILL  0 3  EFLAG FLAGS
    9:   DO   I C@
   10:        IF  DUP I + DUP EFLAG <
   11:            IF    EFLAG SWAP
   12:                  DO  0 I C! DUP  +LOOP
   13:            ELSE  DROP  THEN  SWAP 1+ SWAP
   14:            THEN  2 +
   15:        LOOP  DROP ;
   16: 
   17: : BENCHMARK  0 100 0 DO  PRIMES NIP  LOOP ;
   18: SECS BENCHMARK . SECS SWAP - CR . .( secs)
   19: 
   20: \ HPPA/720, 50 MHz: user 3.90s

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>