Last change
on this file was
432,
checked in by alain, 10 years ago
|
1) Introduce the "applications" directory.
2) Introduce the fixed format (X_WIDTH / Y_WIDTH / P_WIDTH) for processor index in all applications.
|
File size:
1.1 KB
|
Line | |
---|
1 | #include "stdio.h" |
---|
2 | #include "hard_config.h" |
---|
3 | |
---|
4 | ///////////////////////////////////////// |
---|
5 | __attribute__ ((constructor)) void main() |
---|
6 | { |
---|
7 | unsigned int opx; |
---|
8 | unsigned int opy; |
---|
9 | |
---|
10 | // get processor identifiers |
---|
11 | unsigned int x; |
---|
12 | unsigned int y; |
---|
13 | unsigned int lpid; |
---|
14 | giet_proc_xyp( &x, &y, &lpid ); |
---|
15 | |
---|
16 | giet_tty_printf( "*** Starting task pgcd on processor[%d,%d,%d] at cycle %d\n\n", |
---|
17 | x, y, lpid, giet_proctime() ); |
---|
18 | |
---|
19 | while (1) |
---|
20 | { |
---|
21 | giet_tty_printf("\n*******************\n"); |
---|
22 | giet_tty_printf("operand X = "); |
---|
23 | giet_tty_getw( &opx ); |
---|
24 | giet_tty_printf("\n"); |
---|
25 | giet_tty_printf("operand Y = "); |
---|
26 | giet_tty_getw( &opy ); |
---|
27 | giet_tty_printf("\n"); |
---|
28 | if( (opx == 0) || (opy == 0) ) |
---|
29 | { |
---|
30 | giet_tty_printf("operands must be larger than 0\n"); |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | while (opx != opy) |
---|
35 | { |
---|
36 | if(opx > opy) opx = opx - opy; |
---|
37 | else opy = opy - opx; |
---|
38 | } |
---|
39 | giet_tty_printf("pgcd = %d\n", opx); |
---|
40 | } |
---|
41 | } |
---|
42 | } // end pgcd |
---|
43 | |
---|
Note: See
TracBrowser
for help on using the repository browser.