Mercurial > hg > CbC > old > device
changeset 193:ce0c38b6c85e
try long long
author | kono |
---|---|
date | Sun, 14 Dec 2003 16:53:42 +0900 |
parents | b0d6a6940cb7 |
children | 114e9d64b5cc |
files | Changes test/arg.c test/goto.c test/long.c |
diffstat | 4 files changed, 244 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Tue Dec 02 12:18:54 2003 +0900 +++ b/Changes Sun Dec 14 16:53:42 2003 +0900 @@ -3726,3 +3726,27 @@ lvar cache みたいなものも面白いけど。まぁ、そこまで やるなら、レジスタの寿命とか見ればいいんだよな。。。 +Wed Dec 3 13:11:15 JST 2003 + +スレッドとの相性 +っていうか、こいつをthread libraryとして使うにはどうすればいいの? + env と return を生成する? + +構文的に別にした方が安全だけど。 + +Sun Dec 14 16:26:19 JST 2003 + +long long やるの? 割算はサブルーチン呼び出しみたいね + +float/double から long long, unsigned long long への変換もいるのか。 + F2LL + D2LL + F2ULL + D2ULL + LL2F + LL2D + ULL2F + ULL2D +かぁ。(めんどくさいだけどさ) + +(本気? どれくらいかかる? 2-3日かなぁ...)
--- a/test/arg.c Tue Dec 02 12:18:54 2003 +0900 +++ b/test/arg.c Sun Dec 14 16:53:42 2003 +0900 @@ -4,16 +4,19 @@ int a0;int a1;int a2;int a3;int a4; }; +void *exit_env; +code (*exit_code)(); + code carg1(int arg0,int arg1,int arg2,int arg3,int arg4,code(*exit1)(),void *env) { - printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1,env); + printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit_code,env==exit_env); goto carg2(arg1,arg2,arg3,arg4,arg0,exit1,env); } code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,code(*exit1)(),void *env) { struct arg args0; - printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,sizeof(exit1),sizeof(env)); + printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit_code,env==exit_env ); args0.a0 = arg0; args0.a1 = arg1; args0.a2 = arg2; @@ -26,7 +29,7 @@ { printf("args: %d %d %d %d %d : %x %x\n", args0.a0,args0.a1,args0.a2,args0.a3,args0.a4, - sizeof(exit1),sizeof(env)); + exit1==exit_code,env==exit_env); // goto exit1(321),env; goto (*exit1)(0),env; } @@ -63,7 +66,7 @@ int main1(int n) { - goto carg1(0,1,2,3,4,return,environment); + goto carg1(0,1,2,3,4,exit_code=return,exit_env=environment); return n; }
--- a/test/goto.c Tue Dec 02 12:18:54 2003 +0900 +++ b/test/goto.c Sun Dec 14 16:53:42 2003 +0900 @@ -6,62 +6,76 @@ code a4(int i,code conv()); code a5(int i,code conv()); +char* +print_conv(code conv()) +{ + if(conv==a2) return "a2"; + if(conv==a3) return "a3"; + if(conv==a4) return "a4"; + if(conv==a5) return "a5"; + if(conv==a6) return "a6"; + if(conv==a7) return "a7"; + if(conv==a8) return "a8"; + if(conv==a9) return "a9"; + else return "xx"; +} + code (*exit0)(int); void *env; code a2(int i,code conv()) { - printf("a2 %d %x\n",i,conv); + printf("a2 %d %s\n",i,print_conv(conv)); goto conv(i+1,a4); } code a3(int i,code (*conv)()) { - printf("a3 %d %x\n",i,conv); + printf("a3 %d %s\n",i,print_conv(conv)); goto conv(i+1,a5); } code a4(int i,code conv()) { - printf("a4 %d %x\n",i,conv); + printf("a4 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,a6); } code a5(int i,code (*conv)()) { - printf("a5 %d %x\n",i,conv); + printf("a5 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,i+2,i+3,a7); } code a6(int i,int j,int k,code conv()) { - printf("a6 %d %x\n",i,conv); + printf("a6 %d %s\n",i,print_conv(conv)); goto conv(i+1,j,k,a8); } code a7(int i,,int j,int k,code (*conv)()) { - printf("a7 %d %x\n",i,conv); + printf("a7 %d %s\n",i,print_conv(conv)); goto conv(i+1,j,k,a9); } code a8(int i,int j,int k,code conv()) { - printf("a8 %d %x\n",i,conv); + printf("a8 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,j,k,exit0); } code a9(int i,int j,int k,code (*conv)()) { - printf("a9 %d %x\n",i,conv); + printf("a9 %d %s\n",i,print_conv(conv)); goto (*conv)(0),env; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/long.c Sun Dec 14 16:53:42 2003 +0900 @@ -0,0 +1,191 @@ + +long long gj; +long long gi; + +long long a[100]; +unsigned long long b[100]; +unsigned long long c[100]; + +long long data[] = {2342342342304234LL,2342342340234234LL, -2342342342340234LL}; +unsigned long long udata[] = {2342342334234LL,23423423434234LL, + -234234234234234LL}; + +long long f(long long i,unsigned long long j,unsigned long long k,long long m,long long a); +unsigned +long long g(long long i,unsigned long long j,unsigned long long k,long long m,long long a); + +void +test3(); + +float f2ll(long long i) { float r; + r = i ; + return r; } +double d2ll(long long i) { double r; + r = i ; + return r; } +float f2ull(unsigned long long i) { float r; + r = i ; + return r; } +double d2ull(unsigned long long i) { double r; + r = i ; + return r; } +long long ll2f(float f) { long long r; + r = f ; + return r; } +long long ll2d(double d) { long long r; + r = d ; + return r; } +unsigned long long ull2f(float f) { unsigned long long r; + r = f ; + return r; } +unsigned long long ull2d(double d) { unsigned long long r; + r = d ; + return r; } + +main() +{ + int ii; + long long i,k,*p; + unsigned long long j,m,*up; + unsigned long long g0,h0; + long long g1,h1; + unsigned long long sg0,sh0; + long long sg1,sh1; + unsigned long long *pg0,*ph0; + long long *pg1,*ph1; + unsigned long long *psg0,*psh0; + long long *psg1,*psh1; + + + i = -2343423423424234234LL; + j = 3424223422342234224LL; + k = 44; + k = i*j+3+k; + m = i*j-7+k; + printf("%lld %lld %llu\n",i,k,m); + printf("%lld %lld %llu\n",i,1231234234233LL,m); + + g0 = -2343423423424234234LL; + g0++; --g0; + ++g0; g0--; + printf("g0=%lld\n",g0); + g1 = -2343423423424234234LL; + g1++; --g1; + ++g1; g1--; + printf("g1=%lld\n",g1); + + sg0 = 2343423423424234234LL; + sg0++; --sg0; + ++sg0; sg0--; + printf("sg0=%lld\n",sg0); + sg1 = -2343423423424234234LL; + sg1++; --sg1; + ++sg1; sg1--; + printf("sg1=%lld\n",sg1); + + pg0 = &g0; + ph0 = &h0; + *pg0 = -2343423423424234234LL; + //*pg0++; *--pg0; + //*++pg0; *g0--; + printf("g0=%lld\n",*pg0); + pg1 = &g1; + ph1 = &h1; + *pg1 = -2343423423424234234LL; + //*pg1++; --*pg1; + //++*pg1; *pg1--; + printf("g1=%lld\n",*pg1); + + psg0 = &sg0; + psh0 = &sh0; + *psg0 = -2343423423424234234LL; + //*sg0++; *--sg0; + //*++sg0; *sg0--; + printf("sg0=%lld\n",*psg0); + psg1 = &sg1; + psh1 = &sh1; + *psg1 = -2343423423424234234LL; + //*sg1++; *--sg1; + //*++sg1; *sg1--; + printf("sg1=%lld\n",*psg1); + + + h0 = g0 - 20; + c[33] = g0; + + if (i==j) { printf("i==j\n"); } else { printf("i!=j\n"); } + + a[33] = i; + b[33] = 2342342342342342342LL; + printf("i=%lld\n",i); + printf("j=%lld\n",j); + i++; --i; + j++; --j; + printf("i=%lld\n",i); + printf("j=%lld\n",j); + gi = 2342342342342342342LL; + gj = 2342342342342342342LL; + gi++; --gi; + gj++; --gj; + printf("gi=%lld\n",gi); + printf("gj=%lld\n",gj); + + printf("k=%lld\n",k); + printf("m=%lld\n",m); + printf("a[33]=%lld\n",a[33]); + printf("b[33]=%lld\n",b[33]); + printf("a[33]=%lld\n",++a[33]); + printf("b[33]=%lld\n",b[33]--); + + printf("g0=%lld\n",g0); + printf("h0=%lld\n",h0); + printf("c[33]=%lld\n",c[33]); + + p = data; + printf("*p++ = %lld\n",*p++); + printf("*++p = %lld\n",*++p); + *p++ = -2342342342342342342LL; + printf("*p-- = %lld\n",*p--); + printf("*--p = %lld\n",*--p); + up = udata; + printf("*up-- = %lld\n",*up--); + printf("*--up = %lld\n",*--up); + *up++ = 65530; + printf("*up-- = %lld\n",*up--); + printf("*--up = %lld\n",*--up); + + + ii = f(i,j,k,m,a[33]); + printf("f()=%lld\n",ii); + ii = g(i,j,k,m,a[33]); + printf("f()=%lld\n",ii); + test3(); + return 0; +} + +long long f(long long i,unsigned long long j,unsigned long long k,long long m,long long a) +{ + return i+j*k-m/a; +} + +unsigned +long long g(long long i,unsigned long long j,unsigned long long k,long long m,long long a) +{ + return i+j*k-m/a; +} + +void +test3() +{ + printf("%g %g %g %g %lld %lld %llu %llu\n", +f2ll((long long ) -3423423234234LL), +d2ll((long long ) -3423423234234LL), +f2ull((unsigned long long ) 34234234234234LL), +d2ull((unsigned long long ) 34234234234234LL), +ll2f((float ) 2342423423423424234LL), +ll2d((double ) 2344234234244234234LL), +ull2f((float ) 2344234234244234234LL), +ull2d((double )2332342343234234234LL) +); + +}