257
|
1 #include "stdio.h"
|
|
2 #include <setjmp.h>
|
|
3
|
|
4 // #define __environment _CbC_environment
|
|
5 // #define __return _CbC_return
|
|
6
|
|
7
|
|
8 struct arg {
|
|
9 int a0;int a1;int a2;int a3;int a4;
|
|
10 };
|
|
11
|
|
12 extern void exit(int);
|
|
13
|
|
14 void *exit_env;
|
|
15 __code (*exit___code)();
|
|
16
|
|
17 // #ifndef __llvm__
|
|
18 __code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env);
|
|
19 __code cargs(struct arg args0,__code exit1(int, void*),void *env);
|
|
20 __code carg4(struct arg args0,struct arg args1,int i, int j,int k,int l);
|
|
21 __code carg5(struct arg args0,struct arg args1,int i, int j,int k,int l);
|
|
22 __code carg6(int i, int j,int k,int l,struct arg args0);
|
|
23 // #endif
|
|
24
|
|
25 __code carg1(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env)
|
|
26 {
|
|
27 printf("#0017:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env);
|
|
28 goto carg2(arg1,arg2,arg3,arg4,arg0,exit1,env);
|
|
29 }
|
|
30
|
|
31 __code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env)
|
|
32 {
|
|
33 struct arg args0;
|
|
34 printf("#0024:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env );
|
|
35 args0.a0 = arg0;
|
|
36 args0.a1 = arg1;
|
|
37 args0.a2 = arg2;
|
|
38 args0.a3 = arg3;
|
|
39 args0.a4 = arg4;
|
|
40 goto cargs(args0,exit1,env);
|
|
41 }
|
|
42
|
|
43 __code cargs(struct arg args0,__code exit1(int, void*),void *env)
|
|
44 {
|
|
45 printf("#0035:args: %d %d %d %d %d : %x %x\n",
|
|
46 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,
|
|
47 exit1==exit___code,env==exit_env);
|
|
48 // goto exit1(321),env;
|
|
49 goto (*exit1)(0,env);
|
|
50 }
|
|
51
|
|
52
|
|
53 __code carg3(struct arg args0,struct arg args1,int i, int j,int k,int l)
|
|
54 {
|
|
55 printf("#0045:args3: %d %d %d %d %d : %x %x %x %x\n",
|
|
56 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
|
|
57 printf("#0047:args3: args0 %d %d %d %d %d : args1 %d %d %d %d %d : %x %x %x %x\n",
|
|
58 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,
|
|
59 args1.a0,args1.a1,args1.a2,args1.a3,args1.a4,
|
|
60 i,j,k,l);
|
|
61 if (args0.a0==args1.a0) exit(0);
|
|
62 goto carg4(args0,args1,j,k,l,i);
|
|
63 }
|
|
64
|
|
65 __code carg4(struct arg args0,struct arg args1,int i, int j,int k,int l)
|
|
66 {
|
|
67 printf("#0057:args4: %d %d %d %d %d : %x %x %x %x\n",
|
|
68 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
|
|
69 goto carg5(args1,args0,j,k,l,i);
|
|
70 }
|
|
71
|
|
72 __code carg5(struct arg args0,struct arg args1,int i, int j,int k,int l)
|
|
73 {
|
|
74 printf("#0064:args5: %d %d %d %d %d : %x %x %x %x\n",
|
|
75 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
|
|
76 goto carg6(i,j,k,l,args0);
|
|
77 }
|
|
78
|
|
79 __code carg6(int i, int j,int k,int l,struct arg args0)
|
|
80 {
|
|
81 printf("#0071:args6: %d %d %d %d %d : %x %x %x %x\n",
|
|
82 args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
|
|
83 goto carg3(args0,args0,i,j,k,l);
|
|
84 }
|
|
85
|
|
86 struct __CbC_env {
|
|
87 int n;
|
|
88 jmp_buf ret_p;
|
|
89 };
|
|
90
|
|
91 __code __return(int n, void *env)
|
|
92 {
|
|
93 struct __CbC_env *ce = (struct __CbC_env *)env;
|
|
94 ce->n = n;
|
|
95 longjmp(ce->ret_p,1);
|
|
96 }
|
|
97
|
|
98 int main1(int n)
|
|
99 {
|
|
100 struct __CbC_env ce;
|
|
101 if (setjmp(ce.ret_p) == 0) {
|
|
102 goto carg1(0,1,2,3,4,exit___code=__return,exit_env= &ce);
|
|
103 } else {
|
|
104 n = ce.n;
|
|
105 }
|
|
106 return n;
|
|
107 }
|
|
108
|
|
109 struct arg a00;
|
|
110 struct arg a01;
|
|
111
|
|
112 int main( int ac, char *av[])
|
|
113 {
|
|
114 int n;
|
|
115 n = main1(123);
|
|
116 printf("#0089:321=%d\n",n);
|
|
117
|
|
118 a00.a0 = 11;
|
|
119 a00.a1 = 22;
|
|
120 a00.a2 = 33;
|
|
121 a00.a3 = 44;
|
|
122 a00.a4 = 55;
|
|
123 a01.a0 = 66;
|
|
124 a01.a1 = 77;
|
|
125 a01.a2 = 88;
|
|
126 a01.a3 = 99;
|
|
127 a01.a4 = 10;
|
|
128 goto carg3(a00,a01,1,2,3,4);
|
|
129 }
|
|
130
|