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
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"
d35df41eac69 Initial revision
kono
parents:
diff changeset
5
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
6 __code factorial(int n,int result,int orig,__code(*print)(),__code(*exit1)(), void *exit1env)
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
7 {
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
8 if (n<0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
9 printf("#0008:err %d!\n",n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
10 goto (*exit1)(0,exit1env);
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
11 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
12 if (n==0)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
13 goto (*print)(n,result,orig,print,exit1,exit1env);
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
14 else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
15 result *= n;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
16 n--;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
17 goto factorial(n,result,orig,print,exit1,exit1env);
5
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
18 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
19 }
3db1b6d78412 *** empty log message ***
kono
parents: 0
diff changeset
20
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
21 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env);
572
388baa7d4bee more strict errors.
kono
parents: 427
diff changeset
22
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
23 int main( int ac, char *av[])
d35df41eac69 Initial revision
kono
parents:
diff changeset
24 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
25 int n;
172
096559f07a70 some check
kono
parents: 53
diff changeset
26 // n = atoi(av[1]);
096559f07a70 some check
kono
parents: 53
diff changeset
27 n = 10;
720
6b7372e17970 *** empty log message ***
kono
parents: 622
diff changeset
28 goto factorial(n,1,n,print,__return,__environment);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
29 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
30
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
31 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
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
d35df41eac69 Initial revision
kono
parents:
diff changeset
35 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
36