changeset 15:6667dbd4f718 struct-copy

eax before function call
author kono
date Mon, 17 Jan 2000 02:04:48 +0900
parents 77c0710a8729
children ca0bce3b4810
files mc-nop-386.c test/tmp7.c
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mc-nop-386.c	Mon Jan 17 01:20:59 2000 +0900
+++ b/mc-nop-386.c	Mon Jan 17 02:04:48 2000 +0900
@@ -845,8 +845,9 @@
 	use_register(creg,REG_EAX,0);
 	printf("\tcall\t%s\n",n->nm);
     } else {	
+	use_register(creg,REG_EAX,0);
 	g_expr(e2);
-	use_register(creg,REG_EAX,0);
+	use_register(creg,REG_EAX,1);
 	printf("\tcall\t*%s\n",crn);
     }
     if (nargs) printf("\taddl $%d,%%esp\n",size_of_int*nargs);
@@ -1040,7 +1041,7 @@
     emit_push();
     g_expr(e2);
     xrn = emit_pop(0);
-    emit_copy(crn,xrn,sz,0);
+    emit_copy(xrn,crn,sz,0);
     return;
 }
 
--- a/test/tmp7.c	Mon Jan 17 01:20:59 2000 +0900
+++ b/test/tmp7.c	Mon Jan 17 02:04:48 2000 +0900
@@ -17,12 +17,15 @@
 void
 main2(struct aa a1)
 {
-	printf("main2 %d\n",a1.a[99]);
+	printf("main2 a1.a[99] %d\n",a1.a[99]);
+	printf("main2 a1.a[55] %d\n",a1.a[55]);
 }
 
 struct aa 
 main1(struct aa a1)
 {
+    printf("main1 a1.a[0] %d\n",a1.a[0]);
+    a1.a[55]=44;
     if (a1.a[0]) 
 	main2(a1);
     else
@@ -38,13 +41,20 @@
     register int i;
     register char *p;
     int j = 3;
-    struct a { int b; int (*c)(); } q = {3,main0},r;
+    struct { int b; void (*c)(/*struct aa*/); } q = {3,main1},r;
 
     j = 3;
 
+    printf("%d==3\n",q.b);
     r = q;
-    printf("%d\n",r.b);
+    printf("%d==3\n",r.b);
+    (*r.c)(aaa);
+    printf("main aaa.a[55] %d\n",aaa.a[55]);
+    bbb.a[0]=44; 
     aaa = bbb;
+    aaa.a[99]=55;  /* core dump? */
+    (*r.c)(aaa);
+    printf("main aaa.a[55] %d\n",aaa.a[55]); 
     p = av[0];
     if (!p) return;
     i = p[1];