Mercurial > hg > CbC > old > device
annotate test/fact-a.c @ 935:7672a37e7545 default tip
Raspbery PI ARM support begin
author | kono |
---|---|
date | Sat, 24 Dec 2016 03:02:57 +0000 |
parents | 5313ed059cee |
children |
rev | line source |
---|---|
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
1 #define __environment _CbC_environment |
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
2 #define __return _CbC_return |
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
3 |
0 | 4 #include "stdio.h" |
5 | |
622 | 6 __code factorial(int n,int result,int orig,__code(*print)(),__code(*exit1)(), void *exit1env) |
5 | 7 { |
8 if (n<0) { | |
880 | 9 printf("#0008:err %d!\n",n); |
10 goto (*exit1)(0,exit1env); | |
5 | 11 } |
12 if (n==0) | |
880 | 13 goto (*print)(n,result,orig,print,exit1,exit1env); |
5 | 14 else { |
880 | 15 result *= n; |
16 n--; | |
17 goto factorial(n,result,orig,print,exit1,exit1env); | |
5 | 18 } |
19 } | |
20 | |
622 | 21 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env); |
572 | 22 |
0 | 23 int main( int ac, char *av[]) |
24 { | |
25 int n; | |
172 | 26 // n = atoi(av[1]); |
27 n = 10; | |
720 | 28 goto factorial(n,1,n,print,__return,__environment); |
0 | 29 } |
30 | |
622 | 31 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env) |
0 | 32 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
33 printf("#0032:%d! = %d\n",orig, result); |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
34 goto (*exit1)(0,exit1env); |
0 | 35 } |
36 |