Mercurial > hg > CbC > CbC_gcc
diff CbC-examples/test_para3.c @ 16:4c6926a2b9bc
examples.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 24 Sep 2009 12:51:25 +0900 |
parents | |
children | 26042f4007d5 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC-examples/test_para3.c Thu Sep 24 12:51:25 2009 +0900 @@ -0,0 +1,83 @@ +#include<stdio.h> +#include<stdlib.h> + +struct abc { + int a; + double b; + char c; + double *d; +}; + +struct def { + int d; + struct abc e; + struct abc *f; +}; + +void print_abc(struct abc a){ + printf("\tstruct abc:\n"); + printf("\ta=%d, b=%lf, c=%d, d=%p\n", a.a, a.b, a.c, a.d); +} +void print_def(struct def b){ + printf("\tstruct def:\n"); + printf("\td=%d, f=%p\n", b.d, b.f); + print_abc(b.e); +} + +__code cs_exit(int a){ + printf("cs_exit : a=%d.\n", a); + exit(a); +} + +__code cs0(struct abc a, struct def b, int c){ + printf("cs0 :\n"); + printf("c=%d\n", c); + print_abc(a); + print_def(b); + goto cs_exit( c*a.a+b.e.c ); +} + + +__code cs_goto(int c, struct abc a, struct def b){ + printf("cs_goto :\n"); + printf("c=%d\n", c); + print_abc(a); + print_def(b); + goto cs0(a, b, c); +} + +int function(){ + struct abc A; + struct def B; + A.a = 10, A.b = 20.02, A.c = '\0', A.d = 0xad; + B.d = 30, B.f = 0xbf; + B.e.a = 50, B.e.b = 60.06, B.e.c = '\1', B.e.d = 0xed; + + printf("function :\n"); + print_abc(A); + print_def(B); + //printf("20*%d + 30*%d + 40*%d + 50*%d =\n", a, b, c, d); + goto cs_goto(100, A, B); + return 0; +} + +int main(int argc, char **argv){ + struct abc A; + struct def B; + //int a=10, b=20, c=30, d=40, e=50, f=60, g=70; + A.a = 10, A.b = 20.02, A.c = '\0', A.d = 0xad; + B.d = 30, B.f = 0xbf; + B.e.a = 50, B.e.b = 60.06, B.e.c = '\1', B.e.d = 0xed; + + /* + printf("main :\n"); + print_abc(A); + print_def(B); + //printf("20*%d + 30*%d + 40*%d + 50*%d =\n", a, b, c, d); + goto cs_goto(100, A, B); + */ + function(); + return 0; +} + +