Mercurial > hg > CbC > old > device
annotate test/arg.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 |
---|---|
53 | 1 #include "stdio.h" |
2 | |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
3 #define __environment _CbC_environment |
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
4 #define __return _CbC_return |
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
5 |
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
6 |
53 | 7 struct arg { |
8 int a0;int a1;int a2;int a3;int a4; | |
9 }; | |
10 | |
720 | 11 extern void exit(int); |
12 | |
193 | 13 void *exit_env; |
622 | 14 __code (*exit___code)(); |
193 | 15 |
622 | 16 __code carg1(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(),void *env) |
55 | 17 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
18 printf("#0017:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env); |
55 | 19 goto carg2(arg1,arg2,arg3,arg4,arg0,exit1,env); |
20 } | |
21 | |
622 | 22 __code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(),void *env) |
53 | 23 { |
24 struct arg args0; | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
25 printf("#0024:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env ); |
53 | 26 args0.a0 = arg0; |
27 args0.a1 = arg1; | |
28 args0.a2 = arg2; | |
29 args0.a3 = arg3; | |
30 args0.a4 = arg4; | |
55 | 31 goto cargs(args0,exit1,env); |
53 | 32 } |
33 | |
622 | 34 __code cargs(struct arg args0,__code exit1(),void *env) |
53 | 35 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
36 printf("#0035:args: %d %d %d %d %d : %x %x\n", |
880 | 37 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4, |
622 | 38 exit1==exit___code,env==exit_env); |
77 | 39 // goto exit1(321),env; |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
40 goto (*exit1)(0,env); |
53 | 41 } |
42 | |
43 | |
622 | 44 __code carg3(struct arg args0,struct arg args1,int i, int j,int k,int l) |
57 | 45 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
46 printf("#0045:args3: %d %d %d %d %d : %x %x %x %x\n", |
880 | 47 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l); |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
48 printf("#0047:args3: args0 %d %d %d %d %d : args1 %d %d %d %d %d : %x %x %x %x\n", |
880 | 49 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4, |
50 args1.a0,args1.a1,args1.a2,args1.a3,args1.a4, | |
51 i,j,k,l); | |
172 | 52 if (args0.a0==args1.a0) exit(0); |
57 | 53 goto carg4(args0,args1,j,k,l,i); |
54 } | |
55 | |
622 | 56 __code carg4(struct arg args0,struct arg args1,int i, int j,int k,int l) |
57 | 57 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
58 printf("#0057:args4: %d %d %d %d %d : %x %x %x %x\n", |
880 | 59 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l); |
57 | 60 goto carg5(args1,args0,j,k,l,i); |
61 } | |
62 | |
622 | 63 __code carg5(struct arg args0,struct arg args1,int i, int j,int k,int l) |
57 | 64 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
65 printf("#0064:args5: %d %d %d %d %d : %x %x %x %x\n", |
880 | 66 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l); |
57 | 67 goto carg6(i,j,k,l,args0); |
68 } | |
69 | |
622 | 70 __code carg6(int i, int j,int k,int l,struct arg args0) |
57 | 71 { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
72 printf("#0071:args6: %d %d %d %d %d : %x %x %x %x\n", |
880 | 73 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l); |
57 | 74 goto carg3(args0,args0,i,j,k,l); |
75 } | |
76 | |
54 | 77 int main1(int n) |
78 { | |
720 | 79 goto carg1(0,1,2,3,4,exit___code=__return,exit_env=__environment); |
54 | 80 return n; |
81 } | |
82 | |
79 | 83 struct arg a00; |
84 struct arg a01; | |
85 | |
53 | 86 int main( int ac, char *av[]) |
87 { | |
88 int n; | |
54 | 89 n = main1(123); |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
725
diff
changeset
|
90 printf("#0089:321=%d\n",n); |
79 | 91 |
92 a00.a0 = 11; | |
93 a00.a1 = 22; | |
94 a00.a2 = 33; | |
95 a00.a3 = 44; | |
96 a00.a4 = 55; | |
97 a01.a0 = 66; | |
98 a01.a1 = 77; | |
99 a01.a2 = 88; | |
100 a01.a3 = 99; | |
101 a01.a4 = 10; | |
102 goto carg3(a00,a01,1,2,3,4); | |
53 | 103 } |
104 |