annotate test/fact-a.c @ 720:6b7372e17970

*** empty log message ***
author kono
date Sat, 12 Apr 2008 03:53:11 +0900
parents 682c8ec38d45
children 3f1f6c0610c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1 #include "stdio.h"
d35df41eac69 Initial revision
kono
parents:
diff changeset
2
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
3 __code factorial(int n,int result,int orig,__code(*print)(),__code(*exit1)(), void *exit1env)
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
4 {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
5 if (n<0) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 172
diff changeset
6 printf("#0005:err %d!\n",n);
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
7 goto (*exit1)(0),exit1env;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
8 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
9 if (n==0)
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
10 goto (*print)(n,result,orig,print,exit1,exit1env);
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
11 else {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
12 result *= n;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
13 n--;
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
14 goto factorial(n,result,orig,print,exit1,exit1env);
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
15 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
16 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
17
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
18 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env);
572
388baa7d4bee more strict errors.
kono
parents: 427
diff changeset
19
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
20 int main( int ac, char *av[])
d35df41eac69 Initial revision
kono
parents:
diff changeset
21 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
22 int n;
172
096559f07a70 some check
kono
parents: 53
diff changeset
23 // n = atoi(av[1]);
096559f07a70 some check
kono
parents: 53
diff changeset
24 n = 10;
720
6b7372e17970 *** empty log message ***
kono
parents: 622
diff changeset
25 goto factorial(n,1,n,print,__return,__environment);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
26 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
27
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
28 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
29 {
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
30 printf("#0029:%d! = %d\n",orig, result);
172
096559f07a70 some check
kono
parents: 53
diff changeset
31 goto (*exit1)(0),exit1env;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
32 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
33