fixing a bug did write end code for frame pointer that we do not have

tempary fix, we can not optimize code so good yet. so if it more that 4 register same time we are using own frame, ebx is working as our ebp for we already resvert  the ebp 

svn path=/trunk/; revision=25497
This commit is contained in:
Magnus Olsen 2007-01-17 16:23:39 +00:00
parent af42a0cc24
commit 65747168ef

View file

@ -19,17 +19,14 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
CPU_UNINT tmp;
CPU_INT setup_ebp = 0 ; /* 0 = no, 1 = yes */
if (HowManyRegInUse > 8)
/* Fixme at moment we can not optimze code */
//if (HowManyRegInUse > 9)
if (HowManyRegInUse > 4)
{
setup_ebp =1; /* we will use ebx as ebp */
stack = HowManyRegInUse * regbits;
}
fprintf(outfp,"BITS 32\n");
fprintf(outfp,"GLOBAL _main\n");
fprintf(outfp,"SECTION .text\n\n");
@ -45,6 +42,19 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
fprintf(outfp,"mov ebx,esp\n");
fprintf(outfp,"sub esp, %d ; Alloc %d bytes for reg\n\n",stack,stack);
}
else
{
/*
0 EAX
1 ECX
2 EDX
5 EBX
6 ESP
7 EBP
8 ESI
9 EDI
*/
}
fprintf(outfp,"; Start the program \n");
while (pMystart!=NULL)
@ -95,7 +105,12 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
}
else
{
if (setup_ebp == 1)
fprintf(outfp,"mov dword [ebx - %d], %llu\n", tmp, pMystart->src);
else
{
fprintf(outfp,"unsuported optimze should not happen it happen :(\n", tmp, pMystart->src);
}
}
}
} /* end pMyBrainAnalys->type & 8 */
@ -105,11 +120,14 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
if (pMystart->op == OP_ANY_ret)
{
if (pMyBrainAnalys->ptr_next == NULL)
{
if (setup_ebp == 1)
{
fprintf(outfp,"\n; clean up after the frame \n");
fprintf(outfp,"mov esp, ebx\n");
fprintf(outfp,"pop ebx\n");
}
}
fprintf(outfp,"ret\n");
}
pMystart = (PMYBrainAnalys) pMystart->ptr_next;