changeset 43:a792cf69d698

*** empty log message ***
author kono
date Thu, 13 Feb 2003 17:56:43 +0900
parents a89cf0d6904f
children c9293a6e40d2
files mc-nop-386.c
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mc-nop-386.c	Thu Feb 13 15:56:31 2003 +0900
+++ b/mc-nop-386.c	Thu Feb 13 17:56:43 2003 +0900
@@ -52,7 +52,7 @@
 static void shift(char *op, int xreg) ;
 /* static void st_indexx(int byte, int n, int xreg); */
 static void string(int e1);
-static void tosop(int op);
+static void tosop(int op,int reg);
 static void edx_cleanup();
 static void use_register(int virt, int real, int move);
 static void emit_copy(int from,int to,int length,int offset);
@@ -448,7 +448,7 @@
 {
     if (xreg==dreg) {
 	regv[dreg]=0;
-    } else {
+    } else if (xreg!=-1) {
 	free_register(xreg);
     }
 }
@@ -1217,7 +1217,8 @@
     g_expr(e3);
     emit_push();
     g_expr(e2);
-    tosop(car(e1));
+    tosop(car(e1),(e2=pop_register()));
+    emit_pop_free(e2);
     regv[creg]=1;
     return;
 }
@@ -1298,7 +1299,7 @@
 void
 assop(int e1)
 {
-    int e2,e3,byte,op,new_reg;
+    int e2,e3,byte,op,reg;
     char *xrn;
     int xreg,edx;
 
@@ -1310,25 +1311,24 @@
     op = cadddr(e1);
 
     g_expr(e3);
-    emit_push();
     if (car(e2)==REGISTER) {
-	new_reg=creg;
-	creg = cadr(e2);
-	tosop(op);
-	creg = new_reg;
-	printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(creg,0));
+	xreg = creg;
+	creg = reg = cadr(e2);
+	tosop(op,xreg);
+	creg = xreg;
+	printf("\tmovl %s,%s\n",register_name(reg,0),register_name(creg,0));
 	regv[creg]=1;
 	return;
     }
+    emit_push();
     g_expr(e2);
     edx = edx_setup();
     xrn = register_name(xreg = emit_pop(0),0);       /* pop e3 value */
     regv[xreg]=regs[xreg]=1;
     printf("\tmovl %s,%s  # assop \n",register_name(creg,0),register_name(edx,0));
     regv[edx]=1;
-    emit_push_x(xreg);
     ld_indexx(byte,0,edx);
-    tosop(op);
+    tosop(op,xreg);
     printf("\t%s %s,(%s)\n",byte ? "movb" : "movl",register_name(creg,byte),register_name(edx,0));
     edx_cleanup();
     emit_pop_free(xreg);
@@ -1338,12 +1338,11 @@
 
 
 void
-tosop(int op)
+tosop(int op,int oreg)
 {
-    int oreg,dx;
+    int dx;
     char *orn,*crn;
 
-    oreg = pop_register();
     switch(op) {
     case LSHIFT:
     case ULSHIFT: