annotate test/conv.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: 721
diff changeset
1 #define __environment _CbC_environment
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
2 #define __return _CbC_return
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
3
170
6e0f67b7d200 test files
kono
parents:
diff changeset
4 #include "stdio.h"
6e0f67b7d200 test files
kono
parents:
diff changeset
5
6e0f67b7d200 test files
kono
parents:
diff changeset
6 f0(int i) {
6e0f67b7d200 test files
kono
parents:
diff changeset
7 int k,j;
6e0f67b7d200 test files
kono
parents:
diff changeset
8 k = 3+i;
6e0f67b7d200 test files
kono
parents:
diff changeset
9 j = g0(i+3);
6e0f67b7d200 test files
kono
parents:
diff changeset
10 return k+4+j;
6e0f67b7d200 test files
kono
parents:
diff changeset
11 }
6e0f67b7d200 test files
kono
parents:
diff changeset
12
6e0f67b7d200 test files
kono
parents:
diff changeset
13 g0(int i) {
6e0f67b7d200 test files
kono
parents:
diff changeset
14 return i+4;
6e0f67b7d200 test files
kono
parents:
diff changeset
15 }
6e0f67b7d200 test files
kono
parents:
diff changeset
16
6e0f67b7d200 test files
kono
parents:
diff changeset
17 typedef char *stack;
6e0f67b7d200 test files
kono
parents:
diff changeset
18
6e0f67b7d200 test files
kono
parents:
diff changeset
19 struct cont_interface { // General Return Continuation
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
20 __code (*ret)();
170
6e0f67b7d200 test files
kono
parents:
diff changeset
21 };
6e0f67b7d200 test files
kono
parents:
diff changeset
22
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
23 __code f(int i,stack sp) {
170
6e0f67b7d200 test files
kono
parents:
diff changeset
24 int k,j;
6e0f67b7d200 test files
kono
parents:
diff changeset
25 k = 3+i;
6e0f67b7d200 test files
kono
parents:
diff changeset
26 goto f_g0(i,k,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
27 }
6e0f67b7d200 test files
kono
parents:
diff changeset
28
6e0f67b7d200 test files
kono
parents:
diff changeset
29 struct f_g0_interface { // Specialized Return Continuation
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
30 __code (*ret)();
170
6e0f67b7d200 test files
kono
parents:
diff changeset
31 int i_,k_,j_;
6e0f67b7d200 test files
kono
parents:
diff changeset
32 };
6e0f67b7d200 test files
kono
parents:
diff changeset
33
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
34 __code f_g1(int j,stack sp);
170
6e0f67b7d200 test files
kono
parents:
diff changeset
35
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
36 __code f_g0(int i,int k,stack sp) { // Caller
170
6e0f67b7d200 test files
kono
parents:
diff changeset
37 struct f_g0_interface *c =
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
38 (struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
170
6e0f67b7d200 test files
kono
parents:
diff changeset
39
6e0f67b7d200 test files
kono
parents:
diff changeset
40 c->ret = f_g1;
6e0f67b7d200 test files
kono
parents:
diff changeset
41 c->k_ = k;
6e0f67b7d200 test files
kono
parents:
diff changeset
42 c->i_ = i;
6e0f67b7d200 test files
kono
parents:
diff changeset
43
6e0f67b7d200 test files
kono
parents:
diff changeset
44 goto g(i+3,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
45 }
6e0f67b7d200 test files
kono
parents:
diff changeset
46
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
47 __code f_g1(int j,stack sp) { // Continuation
721
76761a18703b Recursive macro
kono
parents: 622
diff changeset
48 struct f_g0_interface *c = (struct f_g0_interface *)sp;
170
6e0f67b7d200 test files
kono
parents:
diff changeset
49 int k = c->k_;
6e0f67b7d200 test files
kono
parents:
diff changeset
50 sp += sizeof(struct f_g0_interface);
6e0f67b7d200 test files
kono
parents:
diff changeset
51 goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
52 }
6e0f67b7d200 test files
kono
parents:
diff changeset
53
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
54 __code g(int i,stack sp) {
170
6e0f67b7d200 test files
kono
parents:
diff changeset
55 goto (( (struct cont_interface *)sp)->ret)(i+4,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
56 }
6e0f67b7d200 test files
kono
parents:
diff changeset
57
6e0f67b7d200 test files
kono
parents:
diff changeset
58 struct main_continuation { // General Return Continuation
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
59 __code (*ret)();
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
60 __code (*main_ret)();
170
6e0f67b7d200 test files
kono
parents:
diff changeset
61 void *env;
6e0f67b7d200 test files
kono
parents:
diff changeset
62 };
6e0f67b7d200 test files
kono
parents:
diff changeset
63
622
682c8ec38d45 _code へ
kono
parents: 427
diff changeset
64 __code main_return(int i,stack sp) {
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
65 printf("#0064:%d\n",i);
725
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
66 goto (( (struct main_continuation *)sp)->main_ret)(0,
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
67 ((struct main_continuation *)sp)->env);
170
6e0f67b7d200 test files
kono
parents:
diff changeset
68 }
6e0f67b7d200 test files
kono
parents:
diff changeset
69
6e0f67b7d200 test files
kono
parents:
diff changeset
70 #define STACK_SIZE 2048
721
76761a18703b Recursive macro
kono
parents: 622
diff changeset
71 char main_stack[STACK_SIZE];
170
6e0f67b7d200 test files
kono
parents:
diff changeset
72 #define stack_last (&main_stack[STACK_SIZE])
6e0f67b7d200 test files
kono
parents:
diff changeset
73
729
07dce42b67af examples for gcc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
74 int
170
6e0f67b7d200 test files
kono
parents:
diff changeset
75 main()
6e0f67b7d200 test files
kono
parents:
diff changeset
76 {
6e0f67b7d200 test files
kono
parents:
diff changeset
77 struct main_continuation *cont;
6e0f67b7d200 test files
kono
parents:
diff changeset
78 stack sp = stack_last;
6e0f67b7d200 test files
kono
parents:
diff changeset
79
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
80 printf("#0079:%d\n",f0(233));
170
6e0f67b7d200 test files
kono
parents:
diff changeset
81
6e0f67b7d200 test files
kono
parents:
diff changeset
82 sp -= sizeof(*cont);
6e0f67b7d200 test files
kono
parents:
diff changeset
83 cont = (struct main_continuation *)sp;
6e0f67b7d200 test files
kono
parents:
diff changeset
84 cont->ret = main_return;
721
76761a18703b Recursive macro
kono
parents: 622
diff changeset
85 cont->main_ret = __return;
76761a18703b Recursive macro
kono
parents: 622
diff changeset
86 cont->env = __environment;
170
6e0f67b7d200 test files
kono
parents:
diff changeset
87 goto f(233,sp);
729
07dce42b67af examples for gcc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
88
07dce42b67af examples for gcc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
89 return 0;
170
6e0f67b7d200 test files
kono
parents:
diff changeset
90 }
6e0f67b7d200 test files
kono
parents:
diff changeset
91
6e0f67b7d200 test files
kono
parents:
diff changeset
92 /* end */