changeset 633:fbd815a59787

Intel Mac all most done...
author kono
date Wed, 11 Oct 2006 10:07:00 +0900
parents 704b483c3122
children 62c4da637548
files Changes mc-code-ia32.c
diffstat 2 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Wed Oct 11 03:39:45 2006 +0900
+++ b/Changes	Wed Oct 11 10:07:00 2006 +0900
@@ -8923,4 +8923,5 @@
 
 おっと、stack は 16byte alignment でなければならないわけね。
 
-
+あ、そうか。ebp が-12 offset だと、16byte alignment に一致しない。
+
--- a/mc-code-ia32.c	Wed Oct 11 03:39:45 2006 +0900
+++ b/mc-code-ia32.c	Wed Oct 11 10:07:00 2006 +0900
@@ -476,6 +476,9 @@
     if (!lreg||!regs[lreg]) {
 	// long long mode use all registers
 	code_save_stacks();
+#ifdef __APPLE__
+	clear_ptr_cache();
+#endif
     }
     i = lreg = (reg==USE_CREG)?REG_LCREG:reg;
     if (!regs[i]) regs[i]=USING_REG;
@@ -2127,6 +2130,13 @@
     printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
 
     printf("## args %d disp %d  code_disp_offset=%d\n",args,disp,code_disp_offset); 
+#ifdef __APPLE__
+    printf("\tcall\t___i686.get_pc_thunk.bx\n");
+    printf("_%d:\n",labelno);
+    goffset_label = labelno;
+    labelno++;
+    regs[REG_EBX] = 1;
+#endif
 }
 
 void
@@ -2134,7 +2144,7 @@
 {
 #ifdef __APPLE__
     disp &= -(SIZE_OF_INT*4); // 16byte alignment
-    disp -= code_disp_offset-8;
+    disp -= 4;
 #else
     disp &= -SIZE_OF_INT;
 #endif
@@ -3165,6 +3175,7 @@
     g_expr(e2);
     // we are sure %ecx is free
     // %ebx is used in Intel Mac
+    stack_depth -= SIZE_OF_INT * 2;
     printf("\tpopl %%ecx\n");   // LSW
     printf("\tcmpl %%edx,(%%esp)\n");  // MSW
     printf("\tpopl %%edx\n"); 
@@ -3488,12 +3499,16 @@
     } else if (call) {
 #ifdef __APPLE__
 	clear_ptr_cache();
-#endif
 	printf("\tpushl %%edx\n");
 	printf("\tpushl %%eax\n");
 	printf("\tcall %s\n",call);
-	// printf("\taddl $8,%%esp\n");
 	printf("\tlea 16(%%esp),%%esp\n");
+#else
+	printf("\tpushl %%edx\n");
+	printf("\tpushl %%eax\n");
+	printf("\tcall %s\n",call);
+	printf("\tlea 16(%%esp),%%esp\n");
+#endif
 	check_lreg(reg);
     } else {
 	error(-1);