Mercurial > hg > CbC > old > device
annotate test/fact.c @ 751:c921670e2ce8
i64 continue... 64bit register
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 14 Nov 2010 04:56:02 +0900 |
parents | c2c709727221 |
children | 5313ed059cee |
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" |
622 | 5 __code print(); |
0 | 6 int |
7 main(ac,av) | |
8 int ac; | |
9 char *av[]; | |
10 { | |
11 int n; | |
172 | 12 // n = atoi(av[1]); |
13 n = 10; | |
720 | 14 goto factorial(n,1,n,print,__return,__environment); |
0 | 15 } |
16 | |
622 | 17 __code print(n,result,orig,print,exit1,exit1env) |
0 | 18 int n,result,orig; |
622 | 19 __code (*print)(),(*exit1)(); |
0 | 20 void *exit1env; |
21 { | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
22 printf("#0021:%d! = %d\n",n, result); |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
23 goto (*exit1)(0,exit1env); |
0 | 24 } |
25 | |
622 | 26 __code factorial(n,result,orig,print,exit1,exit1env) |
0 | 27 int n,result,orig; |
622 | 28 __code (*print)(); |
29 __code (*exit1)(); | |
0 | 30 void *exit1env; |
31 { | |
32 if (n<0) { | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
33 printf("#0032:err %d!\n",n); |
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 if (n==0) | |
7 | 37 goto (*print)(n,result,orig,print,exit1,exit1env); |
38 /* goto print(n,result,orig,print,exit1,exit1env); */ | |
0 | 39 else { |
40 result *= n; | |
41 n--; | |
42 goto factorial(n,result,orig,print,exit1,exit1env); | |
43 } | |
44 } |