-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.c
More file actions
75 lines (64 loc) · 2.35 KB
/
main.c
File metadata and controls
75 lines (64 loc) · 2.35 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "itm_messages.h"
// ====================================================================================================
// Setup routine called before main
// ====================================================================================================
void SystemInit(void)
{
}
// ====================================================================================================
// ====================================================================================================
// ====================================================================================================
#define N 10000
char notprime[N+1];
// Eratosthenes sieve
static void _sieve(void)
{
int k;
for (int y=0; y<=N; y++)
{
notprime[y]=0;
}
k=2;
while(k<=N)
{
int t=2;
while(t*k<=N)
{
notprime[t*k]=1;
t++;
}
k++;
while(k<=N && notprime[k]==1)
{
k++;
}
}
}
// ====================================================================================================
// ====================================================================================================
// ====================================================================================================
// Externally available routines
// ====================================================================================================
// ====================================================================================================
// ====================================================================================================
int main( void )
{
ITM_ChannelEnable(0);
ITM_Enable();
ITM_SendString( 0,"\n\nSimple Example running\n");
while (1)
{
for (char a='A'; a<'Z'; a++)
{
_sieve();
ITM_Send8(0,a);
}
ITM_SendString(0, "\r\n" __DATE__ "\r\n" __TIME__ "\r\n");
}
/* should not reach this statement */
return 0;
}
// ====================================================================================================