annotate test/test1.c @ 482:8370ba6e8557

*** empty log message ***
author kono
date Sun, 11 Dec 2005 23:23:18 +0900
parents c55363eff5e5
children a379da780856
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
1 /*
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
2 test for CbC converted code from C
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
3 */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
4
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
5 #include "stdio.h"
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
6
172
096559f07a70 some check
kono
parents: 17
diff changeset
7 typedef void *stack;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
8
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
9 void *stack0; /* size of void* == 1 */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
10
172
096559f07a70 some check
kono
parents: 17
diff changeset
11 struct cont_save { /* General Return Continuation */
096559f07a70 some check
kono
parents: 17
diff changeset
12 code (*ret)();
096559f07a70 some check
kono
parents: 17
diff changeset
13 };
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
14
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
15 /*
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
16 code g(int,void *);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
17 code f_g0(int ,int ,void *);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
18 code f_g1(int,void *);
172
096559f07a70 some check
kono
parents: 17
diff changeset
19 */
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
20
172
096559f07a70 some check
kono
parents: 17
diff changeset
21 struct f_g0_save { /* Specialized Return Continuation */
096559f07a70 some check
kono
parents: 17
diff changeset
22 code (*ret)();
096559f07a70 some check
kono
parents: 17
diff changeset
23 int ii,kk,jj;
096559f07a70 some check
kono
parents: 17
diff changeset
24 };
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
25
172
096559f07a70 some check
kono
parents: 17
diff changeset
26 code g(int i,void *sp) {
096559f07a70 some check
kono
parents: 17
diff changeset
27 goto (* ((struct cont_save *)sp)->ret)(i+4,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
28 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
29
172
096559f07a70 some check
kono
parents: 17
diff changeset
30 code f_g1(int j,void *sp) { /* Continuation */
096559f07a70 some check
kono
parents: 17
diff changeset
31 int k;
096559f07a70 some check
kono
parents: 17
diff changeset
32 struct f_g0_save *c;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
33
172
096559f07a70 some check
kono
parents: 17
diff changeset
34 c = sp;
096559f07a70 some check
kono
parents: 17
diff changeset
35 k = c->kk;
096559f07a70 some check
kono
parents: 17
diff changeset
36 sp += sizeof(struct f_g0_save);
096559f07a70 some check
kono
parents: 17
diff changeset
37 goto (* ((struct cont_save *)sp)->ret)(k+4+j,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
38 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
39
172
096559f07a70 some check
kono
parents: 17
diff changeset
40 code f(int i,void *sp) {
096559f07a70 some check
kono
parents: 17
diff changeset
41 int k,j;
096559f07a70 some check
kono
parents: 17
diff changeset
42 struct f_g0_save *c;
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
43 printf("#0036:f 0 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
44
172
096559f07a70 some check
kono
parents: 17
diff changeset
45 k = 3+i;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
46
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
47 printf("#0040:f 1 sp: %x\n",sp-stack0);
172
096559f07a70 some check
kono
parents: 17
diff changeset
48 sp -= sizeof(struct f_g0_save);
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
49 printf("#0042:f 2 sp: %x\n",sp-stack0);
172
096559f07a70 some check
kono
parents: 17
diff changeset
50 c = sp;
096559f07a70 some check
kono
parents: 17
diff changeset
51 c->kk = k;
096559f07a70 some check
kono
parents: 17
diff changeset
52 c->ii = i;
096559f07a70 some check
kono
parents: 17
diff changeset
53 c->jj = j;
096559f07a70 some check
kono
parents: 17
diff changeset
54 c->ret = f_g1;
096559f07a70 some check
kono
parents: 17
diff changeset
55 goto g(i,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
56 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
57
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
58
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
59
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
60 struct f0_save { /* Specialized Return Continuation */
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
61 code (*ret)();
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
62 code (*exit1)();
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
63 void *exit1env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
64 int jj;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
65 };
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
66
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
67 code f0(int i,int j,code(*exit2)(), void *exit2env,void *sp)
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
68 {
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
69 struct f0_save *c;
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
70 printf("#0065:f0 1 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
71 sp -= sizeof(struct f0_save);
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
72 printf("#0067:f0 2 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
73 c = sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
74 c->jj = j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
75 c->exit1 = exit2;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
76 c->exit1env = exit2env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
77 c->ret = f1;
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
78 printf("#0073:f0 3 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
79 goto f(i,sp);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
80 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
81
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
82 code f1(int i,void *sp) {
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
83 int j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
84 int *exit2env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
85 code (*exit2)();
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
86 struct f0_save *c;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
87
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
88 c = sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
89 j = c->jj;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
90 exit2 = c->exit1;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
91 exit2env = c->exit1env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
92
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
93 sp += sizeof(struct f0_save);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
94 goto print(i,j,exit2,exit2env);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
95 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
96
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
97 int main( int ac, char *av[])
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
98 {
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
99 int i,j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
100 int *sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
101
172
096559f07a70 some check
kono
parents: 17
diff changeset
102 // i = atoi(av[1]);
096559f07a70 some check
kono
parents: 17
diff changeset
103 i = 1;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
104 stack0 = ((char *)malloc(1024)+1024);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
105 sp = stack0;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
106 j = i;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
107
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
108 printf("#0103:sp: %x %x\n",sp-(int*)stack0,sizeof(*stack0));
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
109 goto f0(i,j,return,environment,sp);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
110 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
111
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
112 code print(int i,int j,(*exit1)(),void*exit1env)
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
113 {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 172
diff changeset
114 printf("#0109:%d %d\n",i,j);
172
096559f07a70 some check
kono
parents: 17
diff changeset
115 goto (*exit1)(0),exit1env;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
116 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
117