annotate fact-a.c @ 17:a4f44624a253

asm longjmp (can return correct address but return value is wrong)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Sun, 24 Jan 2016 06:01:43 +0900
parents 0d306982c8b9
children 586096c45873
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1 #ifdef GCC
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #define __environment _CbC_environment
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #define __return _CbC_return
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
4 #endif
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "stdio.h"
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
8 __code factorial(int n,int result,int orig,__code(*print)(int,int,int,__code(*)(),__code(*)(),void*),__code(*exit1)(int,void *), void *exit1env)
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 {
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 if (n<0) {
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
11 printf("#0008:err %d!\n",n);
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
12 goto (*exit1)(0,exit1env);
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 }
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 if (n==0)
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 goto (*print)(n,result,orig,print,exit1,exit1env);
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 else {
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17 result *= n;
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
18 n--;
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
19 goto factorial(n,result,orig,print,exit1,exit1env);
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 }
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 int main( int ac, char *av[])
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 {
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
26 int n;
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
27 n = 10;
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
28 goto factorial(n,1,n,print,__return,__environment);
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 }
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
31 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(int, void*),void*exit1env)
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 {
2
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
33 printf("#0032:%d! = %d\n",orig, result);
35d6eabeadb0 modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
34 goto (*exit1)(0,exit1env);
0
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
bacef8675607 init repository
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36