annotate test/fact.c @ 748:c2c709727221

i64 continue... basic.s assembled.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 13 Nov 2010 22:39:40 +0900
parents 3f1f6c0610c1
children 5313ed059cee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d35df41eac69 Initial revision
kono
parents:
diff changeset
4 #include "stdio.h"
622
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
5 __code print();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
6 int
d35df41eac69 Initial revision
kono
parents:
diff changeset
7 main(ac,av)
d35df41eac69 Initial revision
kono
parents:
diff changeset
8 int ac;
d35df41eac69 Initial revision
kono
parents:
diff changeset
9 char *av[];
d35df41eac69 Initial revision
kono
parents:
diff changeset
10 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
11 int n;
172
096559f07a70 some check
kono
parents: 7
diff changeset
12 // n = atoi(av[1]);
096559f07a70 some check
kono
parents: 7
diff changeset
13 n = 10;
720
6b7372e17970 *** empty log message ***
kono
parents: 622
diff changeset
14 goto factorial(n,1,n,print,__return,__environment);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
15 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
16
622
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
17 __code print(n,result,orig,print,exit1,exit1env)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
18 int n,result,orig;
622
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
19 __code (*print)(),(*exit1)();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
20 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
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
d35df41eac69 Initial revision
kono
parents:
diff changeset
24 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
25
622
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
26 __code factorial(n,result,orig,print,exit1,exit1env)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
27 int n,result,orig;
622
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
28 __code (*print)();
682c8ec38d45 _code へ
kono
parents: 572
diff changeset
29 __code (*exit1)();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
30 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
31 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
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
d35df41eac69 Initial revision
kono
parents:
diff changeset
35 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
36 if (n==0)
7
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
37 goto (*print)(n,result,orig,print,exit1,exit1env);
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
38 /* goto print(n,result,orig,print,exit1,exit1env); */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
39 else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
40 result *= n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
41 n--;
d35df41eac69 Initial revision
kono
parents:
diff changeset
42 goto factorial(n,result,orig,print,exit1,exit1env);
d35df41eac69 Initial revision
kono
parents:
diff changeset
43 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
44 }