diff mc-nop-386.c @ 37:412ad2e6c2a2

struct copy
author kono
date Mon, 10 Feb 2003 22:29:12 +0900
parents 9f89cef85b41
children d48d952da354
line wrap: on
line diff
--- a/mc-nop-386.c	Mon Feb 10 10:07:00 2003 +0900
+++ b/mc-nop-386.c	Mon Feb 10 22:29:12 2003 +0900
@@ -55,6 +55,7 @@
 static void tosop(int op);
 static void div_cleanup(char *orn);
 static void use_register(int virt, int real, int move);
+static void emit_copy(char *from,char *to,int length,int offset);
 
 extern int error(int n);
 extern int fwdlabel(void);
@@ -564,6 +565,9 @@
 	use_register(creg,REG_EAX,1);
 	fwddef(e3);
 	return;
+    case RSTRUCT:
+	g_expr(e2);
+	return;
     case SASS: 
 	sassign(e1);
 	return;
@@ -793,7 +797,7 @@
 	printf("\tpushl %%edi\n");
 	printf("\tpushl %%esi\n");
 	printf("\tpushl %%ecx\n");
-	printf("\tleal 12(%%esp),%%di\n");
+	printf("\tleal 12(%%esp),%%edi\n");
 	if (rname[creg]!=REG_ESI)
 		printf("\tmovl %s,%%esi\n",register_name(creg,0));
 	printf("\tmovl $%d,%%ecx\n",length/size_of_int);
@@ -1107,15 +1111,15 @@
     char *xrn;
 
     /* structure assignment */
-    e2 = cadr(e1);
-    e3 = cadr(e2);
-    e4 = caddr(e1);
-    sz = size(cadr(e2));  /* cld rep movsb */
+    e2 = cadr(e1);  /* pointer variable to the struct */
+    e3 = cadr(e2);  /* offset of the variable (distination) */
+    e4 = caddr(e1); /* rright value (source) */
+    sz = cadddr(e1);  /* size of struct or union */
     g_expr(e4);
     emit_push();
     g_expr(e2);
     xrn = register_name(emit_pop(0),0);
-
+    emit_copy(xrn,register_name(creg,0),sz,0);
     return;
 }