comparison CbC-examples/test_csp1.c @ 27:f9b1a53df341

implemented indirect sibcall for ppc.
author kent@teto.cr.ie.u-ryukyu.ac.jp
date Tue, 10 Nov 2009 16:34:29 +0900
parents 4c6926a2b9bc
children
comparison
equal deleted inserted replaced
26:b388631e4738 27:f9b1a53df341
1 #include<stdio.h> 1 #include<stdio.h>
2 #include<stdlib.h> 2 #include<stdlib.h>
3 3
4 //static __code (*csp)(int, int, int, int); 4 //static __code (*csp)(int, int, int, int);
5
6 __code cs_end (int a);
7 __code cs0 (int a, int b, int c, int d);
8 void* freturn ();
9 __code cs_goto (int a, int b, int c, int d);
10 int function (double a, float b, int c);
11 int main (int argc, char **argv);
12
13
14 __code cs_goto(int a, int b, int c, int d){
15 __code (*csp)(int, int, int, int);
16 csp = freturn();
17 printf("csp = %x.\n", csp);
18
19 //printf("cs_goto : a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d.\n", a, b, c, d, e, f, g);
20 //printf("cs_goto : a=%d, b=%d, c=%d, d=%d.\n", a, b, c, d);
21 //printf("cs_goto : a-4=%d, a-8=%d, a-12=%d, a-16=%d.\n", *(&a-4), *(&a-8), *(&a-12), *(&a-16));
22 //printf("cs_goto : cs0(a, b, c, d)\n");
23 #ifdef INDIRECT
24 goto csp(b+a, d+b, a+c, c+d);
25 #else
26 goto cs0(b+a, d+b, a+c, c+d);
27 #endif
28 }
5 29
6 __code cs_end(int a){ 30 __code cs_end(int a){
7 printf("cs_exit : a=%d.\n", a); 31 printf("cs_exit : a=%d.\n", a);
8 exit(a); 32 exit(a);
9 goto cs_end(a); 33 goto cs_end(a);
17 41
18 42
19 void* freturn(){ 43 void* freturn(){
20 return cs0; 44 return cs0;
21 } 45 }
22 __code cs_goto(int a, int b, int c, int d){
23 __code (*csp)(int, int, int, int);
24 csp = freturn();
25 printf("csp = %x.\n", csp);
26
27 //printf("cs_goto : a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d.\n", a, b, c, d, e, f, g);
28 //printf("cs_goto : a=%d, b=%d, c=%d, d=%d.\n", a, b, c, d);
29 //printf("cs_goto : a-4=%d, a-8=%d, a-12=%d, a-16=%d.\n", *(&a-4), *(&a-8), *(&a-12), *(&a-16));
30 //printf("cs_goto : cs0(a, b, c, d)\n");
31 goto csp(b+a, d+b, a+c, c+d);
32 }
33 46
34 int function(double a, float b, int c){ 47 int function(double a, float b, int c){
35 48
36 printf("function:\n"); 49 printf("function:\n");
37 printf("a=%lf, b=%f, c=%d\n", a, b, c); 50 printf("a=%lf, b=%f, c=%d\n", a, b, c);
43 //csp = cs0; 56 //csp = cs0;
44 function(10.01, 20.02, 30); 57 function(10.01, 20.02, 30);
45 return 0; 58 return 0;
46 } 59 }
47 60
48