OpenCores
URL https://opencores.org/ocsvn/pavr/pavr/trunk

Subversion Repositories pavr

[/] [pavr/] [tags/] [noReleaseTag/] [test/] [sieve/] [sieve.c] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 doru
/* -*- mode: c -*-
2
 * $Id: sieve.c,v 1.1.1.1 2003-02-10 04:08:54 doru Exp $
3
 * http://www.bagley.org/~doug/shootout/
4
 */
5
 
6
//#include <stdio.h>
7
//#include <stdlib.h>
8
#include <string.h>
9
//#include <sfr2313.h>
10
//#include <sfr8515.h>
11
 
12
//#define LIM 8192
13
#define LIM       100
14
#define NR_TIMES  1
15
 
16
void main() {
17
   int NUM;
18
   static char flags[LIM + 1];
19
   long i, k;
20
   int count;
21
   //char *txt1="Hello!";
22
 
23
   NUM=NR_TIMES;
24
   count=0;
25
 
26
   while (NUM--) {
27
      count = 0;
28
      for (i=2; i <= LIM; i++) {
29
         flags[i] = 0xff;
30
      }
31
      for (i=2; i <= LIM; i++) {
32
         if (flags[i]) {
33
         // remove all multiples of prime: i
34
         for (k=i+i; k <= LIM; k+=i) {
35
            flags[k] = 0xaa;
36
         }
37
         count++;
38
         }
39
      }
40
   }
41
   while (1) {
42
   }
43
   //printf("Count: %d\n", count);
44
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.