|
Last change
on this file since 160 was
158,
checked in by alain, 13 years ago
|
|
Introducing the giet_vm and some example applications
|
|
File size:
823 bytes
|
| Line | |
|---|
| 1 | #include "stdio.h" |
|---|
| 2 | |
|---|
| 3 | ///////////////////////////////////////// |
|---|
| 4 | __attribute__ ((constructor)) void main() |
|---|
| 5 | { |
|---|
| 6 | unsigned int opx; |
|---|
| 7 | unsigned int opy; |
|---|
| 8 | |
|---|
| 9 | tty_printf(" Interactive PGCD \n"); |
|---|
| 10 | |
|---|
| 11 | while (1) |
|---|
| 12 | { |
|---|
| 13 | tty_printf("\n*******************\n"); |
|---|
| 14 | tty_printf("operand X = "); |
|---|
| 15 | tty_getw_irq(&opx); |
|---|
| 16 | tty_printf("\n"); |
|---|
| 17 | tty_printf("operand Y = "); |
|---|
| 18 | tty_getw_irq(&opy); |
|---|
| 19 | tty_printf("\n"); |
|---|
| 20 | if( (opx == 0) || (opy == 0) ) |
|---|
| 21 | { |
|---|
| 22 | tty_printf("operands must be larger than 0\n"); |
|---|
| 23 | } |
|---|
| 24 | else |
|---|
| 25 | { |
|---|
| 26 | while (opx != opy) |
|---|
| 27 | { |
|---|
| 28 | if(opx > opy) opx = opx - opy; |
|---|
| 29 | else opy = opy - opx; |
|---|
| 30 | } |
|---|
| 31 | tty_printf("pgcd = %d\n", opx); |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | } // end pgcd |
|---|
| 35 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.