# HG changeset patch # User kono # Date 1046829273 -32400 # Node ID 1a723130a2c75c6bc4cc4e3a95b575295c090db9 # Parent f3f75911d62c281a27ca7abcb6d1c3a30a6d82e1 condtional diff -r f3f75911d62c -r 1a723130a2c7 mc-code-ia32.c --- a/mc-code-ia32.c Wed Mar 05 03:41:08 2003 +0900 +++ b/mc-code-ia32.c Wed Mar 05 10:54:33 2003 +0900 @@ -1029,32 +1029,6 @@ printf("\tj%s\t_%d\n",s,l1); } -void -drexpr(int e1, int e2,int l1, int op) -{ - g_expr(list3(DCOMP,e1,e2)); - switch(op) { - case DOP+GT: - printf("\ttestb\t$69,%%ah\n"); - printf("\tje\t_%d\n",l1); - break; - case DOP+GE: - printf("\ttestb\t$5,%%ah\n"); - printf("\tje\t_%d\n",l1); - break; - case DOP+EQ: - printf("\tandb\t$69,%%ah\n"); - printf("\txorb\t$64,%%ah\n"); - printf("\tje\t_%d\n",l1); - break; - case DOP+NEQ: - printf("\tandb\t$69,%%ah\n"); - printf("\txorb\t$64,%%ah\n"); - printf("\tjne\t_%d\n",l1); - break; - } -} - void jcond(int l, char cond) @@ -1475,7 +1449,7 @@ case DDIV: printf("\tfdivrp %%st,%%st(1)\n"); break; case DMUL: printf("\tfmulp %%st,%%st(1)\n"); break; case DCOMP: - printf("\tfxch\t%%st(1)\n"); + /* printf("\tfxch\t%%st(1)\n"); */ printf("\tfucompp\n"); printf("\tfnstsw\t%%ax\n"); break; @@ -1518,6 +1492,32 @@ /* pop */; } +void +drexpr(int e1, int e2,int l1, int op) +{ + g_expr(list3(DCOMP,e1,e2)); + switch(op) { + case DOP+GE: + printf("\ttestb\t$5,%%ah\n"); + printf("\tjne\t_%d\n",l1); + break; + case DOP+GT: + printf("\ttestb\t$69,%%ah\n"); + printf("\tjne\t_%d\n",l1); + break; + case DOP+EQ: + printf("\tandb\t$69,%%ah\n"); + printf("\txorb\t$64,%%ah\n"); + printf("\tjne\t_%d\n",l1); + break; + case DOP+NEQ: + printf("\tandb\t$69,%%ah\n"); + printf("\txorb\t$64,%%ah\n"); + printf("\tje\t_%d\n",l1); + break; + } +} + int dpop_register() { return 1; diff -r f3f75911d62c -r 1a723130a2c7 mc-codegen.c --- a/mc-codegen.c Wed Mar 05 03:41:08 2003 +0900 +++ b/mc-codegen.c Wed Mar 05 10:54:33 2003 +0900 @@ -520,10 +520,10 @@ drexpr(cadr(e1),caddr(e1),l1,DOP+GE); return; case DOP+LT: - drexpr(caddr(e1),cadr(e1),l1,DOP+GE); + drexpr(caddr(e1),cadr(e1),l1,DOP+GT); return; case DOP+LE: - drexpr(caddr(e1),cadr(e1),l1,DOP+GT); + drexpr(caddr(e1),cadr(e1),l1,DOP+GE); return; case DOP+EQ: drexpr(cadr(e1),caddr(e1),l1,DOP+EQ); diff -r f3f75911d62c -r 1a723130a2c7 test/float.c --- a/test/float.c Wed Mar 05 03:41:08 2003 +0900 +++ b/test/float.c Wed Mar 05 10:54:33 2003 +0900 @@ -5,12 +5,13 @@ void print(double d); extern double sin(double); -extern float fsin(float); +// extern float fsin(float); float f = 0.3; double d = 0.3; float f1 = 0.3; double d1 = 0.3; +double d2 = -0.2; int main(int ac,char *av[]) { @@ -19,19 +20,29 @@ g = 1.0; g = -g; - printf("%g\n",g); - if(f==f*1.0) printf("ok\n"); - if(d==f*1.0) printf("ok\n"); - if(f==f1) printf("ok\n"); - if(d==d1) printf("ok\n"); - if(d>d1) printf("ok\n"); - if(d>=d1) printf("ok\n"); - if(d!=d1) printf("ok\n"); + printf("%g\ncond ",g); + if(f==f*1.0) printf("1 "); + if(d==f*1.0) printf("2 "); + if(f==f1) printf("3 "); + if(d==d1) printf("4 "); + if(d==d2) printf("-4 "); + if(d>d1) printf("5 "); + if(d>d2) printf("-5 "); + if(d>=d1) printf("6 "); + if(d>=d2) printf("-6 "); + if(d!=d1) printf("7 "); + if(d!=d2) printf("-7 "); + if(d