# HG changeset patch # User kono # Date 1046848664 -32400 # Node ID 4d1275f8a5b58daf11156f4fd493ed5f74276faf # Parent 3789aef7331df4a050928ad0e4af9eb57de42b51 *** empty log message *** diff -r 3789aef7331d -r 4d1275f8a5b5 mc-code-ia32.c --- a/mc-code-ia32.c Wed Mar 05 13:43:52 2003 +0900 +++ b/mc-code-ia32.c Wed Mar 05 16:17:44 2003 +0900 @@ -1428,23 +1428,25 @@ void code_d2u() { /* fuck you! */ - printf("\tlea -%d(%%esp),%%esp\n",size_of_int*2); + printf("\tlea -%d(%%esp),%%esp\n",size_of_int*3); printf("\tfnstcw (%%esp)\n"); printf("\tmovl (%%esp), %s\n",register_name(creg,0)); printf("\tmovb $12, 1(%%esp)\n"); printf("\tfldcw (%%esp)\n"); printf("\tmovl %s, (%%ebp)\n",register_name(creg,0)); - printf("\tfistpl %d(%%esp)\n",size_of_int); + printf("\tfistpll %d(%%esp)\n",size_of_int); printf("\tfldcw (%%esp)\n"); - printf("\tpopl %s\n",register_name(creg,0)); - printf("\tpopl %s\n",register_name(creg,0)); + printf("\tmovl %d(%%esp),%s\n",size_of_int,register_name(creg,0)); + printf("\tlea %d(%%esp),%%esp\n",size_of_int*3); } void code_u2d() { - printf("\tpushl %s\n",register_name(creg,0)); - printf("\tfildl (%%esp)\n"); - printf("\tlea %d(%%esp),%%esp\n",size_of_int); + printf("\tpushl %s\n",register_name(creg,0)); + printf("\tpushl %s\n",register_name(creg,0)); + printf("\tmovl $0, %d(%%esp)\n",size_of_int); + printf("\tfildll (%%esp)\n"); + printf("\tlea %d(%%esp),%%esp\n",size_of_int*2); } void code_drgvar(int e2,int d) @@ -1496,7 +1498,7 @@ g_expr(e2); printf("\t%s (%s)\n",fload(d),register_name(creg,0)); printf("\tfld1\n"); - if (e2>0) + if (cadr(e1)>0) printf("\tfaddp %%st,%%st(1)\n"); else printf("\tfsubrp %%st,%%st(1)\n"); @@ -1508,15 +1510,13 @@ g_expr(e2); printf("\t%s (%s)\n",fload(d),register_name(creg,0)); if (use) - /* dup */; + printf("\t%s (%s)\n",fload(d),register_name(creg,0)); printf("\tfld1\n"); - if (e2>0) + if (cadr(e1)>0) printf("\tfaddp %%st,%%st(1)\n"); else printf("\tfsubrp %%st,%%st(1)\n"); - printf("\t%s (%s)\n",fstore_u(d),register_name(creg,0)); - if (use) - /* pop */; + printf("\t%s (%s)\n",fstore(d),register_name(creg,0)); } void diff -r 3789aef7331d -r 4d1275f8a5b5 mc-parse.c --- a/mc-parse.c Wed Mar 05 13:43:52 2003 +0900 +++ b/mc-parse.c Wed Mar 05 16:17:44 2003 +0900 @@ -1655,7 +1655,7 @@ int_value(int e2,int type) { if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(int)dcadr(e2)); - if(scalar(type)) return e2; + if(scalar(type)||car(type)==ARRAY) return e2; if(type==FLOAT||type==DOUBLE) return list2(D2I,e2); error(TYERR); return list2(CONST,1); } @@ -1664,7 +1664,7 @@ unsigned_value(int e2,int type) { if(scalar(type)) return e2; - if(type==FLOAT||type==DOUBLE) list2(D2U,e2); + if(type==FLOAT||type==DOUBLE) return list2(D2U,e2); error(TYERR); return e2; } @@ -1693,7 +1693,7 @@ e2=float_value(e2,type); type= t;return(list3(FASS,e1,e2)); } else if(scalar(t)) { - e2=int_value(e2,type); + e2=(t==UNSIGNED)?unsigned_value(e2,type):int_value(e2,type); type=t; return(list3(ASS,e1,e2)); } else if((car(t)==STRUCT||car(t)==UNION)) { @@ -1757,11 +1757,11 @@ if(!(integral(type)||type==FLOAT||type==DOUBLE)) error(TYERR); if (t==FLOAT) { e2=float_value(e2,type); type=t; - return(list4(FASSOP,e1,e2,op)); + return(list4(FASSOP,e1,e2,op+DOP)); } if (t==DOUBLE) { e2=float_value(e2,type); type=t; - return(list4(DASSOP,e1,e2,op)); + return(list4(DASSOP,e1,e2,op+DOP)); } if(!integral(type)) error(TYERR); if((t==UNSIGNED||type==UNSIGNED)&& diff -r 3789aef7331d -r 4d1275f8a5b5 test/float.c --- a/test/float.c Wed Mar 05 13:43:52 2003 +0900 +++ b/test/float.c Wed Mar 05 16:17:44 2003 +0900 @@ -46,7 +46,7 @@ f = g = d = g = d = f; printf(" %d %g %f %g\n",i,d,f,g); - d = 4294967295.4234; f=4294967295.4234; + d = 4204967294.4234; f=4204967294.4234; u = d; d = u; u = f; @@ -133,11 +133,13 @@ printf("%d:%g\t",n++,f); printf("\n"); - g = g1++ - ++g1; - printf("%d:%g\t",n++,g); + g1 = g; + g1 = g1++ - ++g; + printf("%d:%g\t",n++,g1); - g = f1++ - ++f1; - printf("%d:%g\t",n++,g); + f1 = f; + f1 = f1++ - ++f; + printf("%d:%g\t",n++,f1); g = f+f; printf("%d:%g\t",n++,g); @@ -180,11 +182,14 @@ printf("%d:%g\t",n++,*pf); printf("\n"); - *pg = (*pg1)++ - ++(*pg1); - printf("%d:%g\t",n++,*pg); + *pg1 = *pg; + *pg1 = (*pg1)++ - ++(*pg); + printf("%d:%g\t",n++,*pg1); - *pg = (*pf1)++ - ++(*pf1); - printf("%d:%g\t",n++,*pg); + *pf1 = *pf; + *pf1 = (*pf1)++ - ++(*pf); + printf("%d:%g\t",n++,*pf1); + *pg = *pf+*pf; printf("%d:%g\t",n++,*pg);