diff mc-nop-386.c @ 6:bf602558130d

continuation
author kono
date Thu, 13 Jan 2000 13:41:09 +0900
parents 3db1b6d78412
children e2c2c0fe0785
line wrap: on
line diff
--- a/mc-nop-386.c	Thu Jan 13 12:07:28 2000 +0900
+++ b/mc-nop-386.c	Thu Jan 13 13:41:09 2000 +0900
@@ -86,7 +86,7 @@
             see enter/enter1/leave
  */
 int arg_offset = 8;
-int code_arg_offset = -4; /* depends on number of args */
+int code_arg_offset = -4;
 int disp_offset = -12;
 int func_disp_offset = -12;
 int code_disp_offset = -4;
@@ -763,7 +763,7 @@
 	use_register(creg,REG_EAX,0);
 	printf("\tcall\t*%s\n",crn);
     }
-    if (nargs) printf("\taddl $%d,%%esp\n",4*nargs);
+    if (nargs) printf("\taddl $%d,%%esp\n",size_of_int*nargs);
 }
 
 int
@@ -792,7 +792,7 @@
 {
     int i,args,e2,e3,e4,e5,nargs,nargs0,regs;
     NMTBL *n,*code0;
-    int new_disp,scode,scode_arg_offset,disp1;
+    int new_disp,scode,disp1;
     char *xrn;
 
     /* We need three passes. Compute Stack size, Compute Arg, Copy it. */
@@ -802,7 +802,10 @@
     nargs = arg_size(args,&new_disp);  /* compute in normal order */
     disp1 = (fnptr->sc==CODE)?0:-size_of_int;
     if (new_disp+disp1 < disp) {  /* have to extend stack */
-	printf("\tleal %d(%%ebp),%%esp\n",new_disp-size_of_int);
+	if (fnptr->sc==CODE)
+	    printf("\tleal %d(%%ebp),%%esp\n",new_disp-size_of_int);
+	else
+	    printf("\tleal %d(%%ebp),%%esp\n",new_disp+disp_offset);
     }
     /* compute jump address */
     e2 = cadr(e1);
@@ -865,8 +868,6 @@
     } 
     /* force lvar offset mode to CODE */
     scode = fnptr->sc; fnptr->sc = CODE;
-    scode_arg_offset  = code_arg_offset;
-    code_arg_offset  = new_disp;
 /* printf("# jump2 code_arg_offset=%d code_disp_offset=%d\n",code_arg_offset,code_disp_offset); */
     /* copy arguments to destination environment if necessary */
     nargs = reverse0(nargs); /* pop in normal order */
@@ -901,7 +902,7 @@
     if (car(e2) != FNAME) {	
 	xrn=emit_pop(0);
     }
-    if (new_disp+disp1>disp) {
+    if (!env && new_disp+disp1>disp) {
 	/* shrink stack if necessary */
 	printf("\tleal %d(%%ebp),%%esp\n",new_disp-size_of_int);
     } 
@@ -911,7 +912,6 @@
 	printf("\tjmp *%s\n",xrn);
     }
     fnptr->sc = scode;
-    code_arg_offset  = scode_arg_offset;
 }
 
 
@@ -1304,13 +1304,12 @@
 }
 
 void
-code_enter1(int disp,int args)
+code_enter1(int disp0,int args)
 {
-    if(disp) {
-	printf("\tsubl $%d,%%esp\n",-disp);
+    if(disp0) {
+	printf("\tsubl $%d,%%esp\n",-disp0);
     }
-    code_arg_offset  = -args;
-/* printf("# args %d code_arg_offset=%d code_disp_offset=%d\n",args,code_arg_offset,code_disp_offset); */
+printf("# args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset); 
 }
 
 void