changeset 84:1a723130a2c7

condtional
author kono
date Wed, 05 Mar 2003 10:54:33 +0900
parents f3f75911d62c
children 3789aef7331d
files mc-code-ia32.c mc-codegen.c test/float.c
diffstat 3 files changed, 51 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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);
--- 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<d1) printf("8 ");
+   if(d<d2) printf("-8 ");
+   if(d<=d1) printf("9 ");
+   if(d<=d2) printf("-9 ");
    i = d;
    d = i;
    i = f;
    f = i;
+   printf("\n%d %g %f",i,d,f);
    f = g = d = g = d = f;
+   printf(" %d %g %f %g\n",i,d,f,g);
 
    print(1.0);
    print(0.1234);
@@ -51,11 +62,11 @@
     f = d;
 
     dd = (int*) &d;
-    printf("d %g\n",d);
+    printf("d %g ",d);
     printf("dx %08x %08x\n",*(dd),*(dd+1));
 
     dd = (int*) &f;
-    printf("f %g\n",f);
+    printf("f %g ",f);
     printf("dx %08x \n",*(dd));
 }