ADSP-21020 example: source file example.c

 1  typedef unsigned int uint;
 2  
 3  void Foo (int num, uint *x);
 4  void Solve (uint *x);
 5  void Count (int u, uint *x);
 6  int Ones (uint x);
 7  
 8  void main (void)
 9  {
10     uint x;
11     Foo (6, &x);
12     Solve (&x);
13  }
14  
15  
16  void Foo (int num, uint *x)
17  {
18     Count (num + 3, x);
19  }
20  
21  
22  void Count (int u, uint *x)
23  {
24     for (; u > 0; u -= 2)
25     {   *x = *x * u;
26     }
27  }
28  
29  
30  void Solve (uint *x)
31  {
32     int i, k;
33     for (i = 0; i < 8; i++)
34     {
35        k = Ones (*x);
36        if (k == 0) break;
37        Count (k, x);
38     }
39  }
40  
41  
42  int Ones (uint x)
43  {
44     int v = 0;
45     while (x)
46     {
47        if (x & 1) v ++;
48        x >>= 1;
49     }
50     return v;
51  }