mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 18:42:32 +00:00
fixing the ppc to ia32 break, use ebx as ebp if we got to many register.
svn path=/trunk/; revision=25496
This commit is contained in:
parent
69999a5ad4
commit
af42a0cc24
5 changed files with 90 additions and 40 deletions
|
@ -22,6 +22,7 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
|
|||
if (HowManyRegInUse > 8)
|
||||
{
|
||||
setup_ebp =1; /* we will use ebx as ebp */
|
||||
stack = HowManyRegInUse * regbits;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,13 +37,17 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
|
|||
fprintf(outfp,"_main:\n");
|
||||
|
||||
/* setup a frame pointer */
|
||||
//fprintf(outfp,"\n; Setup frame pointer \n");
|
||||
//fprintf(outfp,"push ebp\n");
|
||||
//fprintf(outfp,"mov ebp,esp\n");
|
||||
//fprintf(outfp,"sub esp, %d ; Alloc %d bytes for reg\n\n",stack,stack);
|
||||
|
||||
if (setup_ebp == 1)
|
||||
{
|
||||
fprintf(outfp,"\n; Setup frame pointer \n");
|
||||
fprintf(outfp,"push ebx\n");
|
||||
fprintf(outfp,"mov ebx,esp\n");
|
||||
fprintf(outfp,"sub esp, %d ; Alloc %d bytes for reg\n\n",stack,stack);
|
||||
}
|
||||
|
||||
fprintf(outfp,"; Start the program \n");
|
||||
while (pMystart!=pMyend)
|
||||
while (pMystart!=NULL)
|
||||
{
|
||||
/* fixme the line lookup from anaylysing process */
|
||||
|
||||
|
@ -60,7 +65,7 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
|
|||
{
|
||||
/* source are imm */
|
||||
|
||||
if (pMyBrainAnalys->dst == eax)
|
||||
if (pMystart->dst == eax)
|
||||
{
|
||||
if (pMystart->src == 0)
|
||||
fprintf(outfp,"xor eax,eax\n");
|
||||
|
@ -90,8 +95,7 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
|
|||
}
|
||||
else
|
||||
{
|
||||
//fprintf(outfp,"mov dword [ebp - %d], %llu\n", tmp, pMystart->src);
|
||||
printf("not support move from register\n");
|
||||
fprintf(outfp,"mov dword [ebx - %d], %llu\n", tmp, pMystart->src);
|
||||
}
|
||||
}
|
||||
} /* end pMyBrainAnalys->type & 8 */
|
||||
|
@ -100,12 +104,12 @@ CPU_INT ConvertToIntelProcess( FILE *outfp, CPU_INT eax, CPU_INT ebp,
|
|||
/* return */
|
||||
if (pMystart->op == OP_ANY_ret)
|
||||
{
|
||||
//if (pMyBrainAnalys->ptr_next == NULL)
|
||||
//{
|
||||
// fprintf(outfp,"\n; clean up after the frame \n");
|
||||
// fprintf(outfp,"mov esp, ebp\n");
|
||||
// fprintf(outfp,"pop ebp\n");
|
||||
//}
|
||||
if (pMyBrainAnalys->ptr_next == NULL)
|
||||
{
|
||||
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;
|
||||
|
|
71
rosapps/devutils/cputointel/ConvertingProcess.c
Normal file
71
rosapps/devutils/cputointel/ConvertingProcess.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
#include <windows.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
#include "any_op.h"
|
||||
|
||||
/* hack should be in misc.h*/
|
||||
|
||||
|
||||
CPU_INT ConvertProcess(FILE *outfp, CPU_INT FromCpuid, CPU_INT ToCpuid)
|
||||
{
|
||||
CPU_INT ret=0;
|
||||
CPU_INT eax =-1;
|
||||
CPU_INT ebp =-1;
|
||||
CPU_INT edx =-1;
|
||||
CPU_INT esp =-1;
|
||||
CPU_INT regbits=-1;
|
||||
CPU_INT HowManyRegInUse = 0;
|
||||
|
||||
PMYBrainAnalys pMystart = pStartMyBrainAnalys;
|
||||
PMYBrainAnalys pMyend = pMyBrainAnalys;
|
||||
|
||||
if (FromCpuid == IMAGE_FILE_MACHINE_POWERPC)
|
||||
{
|
||||
regbits = 32 / 8;
|
||||
esp = 1;
|
||||
eax = 3;
|
||||
edx = 4;
|
||||
ebp = 31;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME calc where todo first split */
|
||||
|
||||
/* FIXME calc who many register are in use */
|
||||
|
||||
//ret = ConvertToIntelProcess(FILE *outfp,
|
||||
// CPU_INT eax,
|
||||
// CPU_INT edx,
|
||||
// CPU_INT edx,
|
||||
// CPU_INT esp,
|
||||
// PMYBrainAnalys start,
|
||||
// PMYBrainAnalys end);
|
||||
|
||||
|
||||
|
||||
switch (ToCpuid)
|
||||
{
|
||||
case IMAGE_FILE_MACHINE_I386:
|
||||
ret = ConvertToIntelProcess( outfp, eax, ebp,
|
||||
edx, esp,
|
||||
pMystart,
|
||||
pMyend, regbits,
|
||||
HowManyRegInUse);
|
||||
if (ret !=0)
|
||||
{
|
||||
printf("should not happen contact a devloper, x86 fail\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("should not happen contact a devloper, unknown fail\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -59,16 +59,6 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
|
|||
|
||||
cpuint = GetData32Le(&cpu_buffer[cpu_pos]);
|
||||
|
||||
///* Add */
|
||||
//if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Addx))) == ConvertBitToByte32(cpuPPCInit_Addx))
|
||||
//{
|
||||
// retsize = PPC_Addx( outfp, cpu_buffer, cpu_pos, cpu_size,
|
||||
// BaseAddress, cpuarch, mode);
|
||||
// if (retsize<0)
|
||||
// retcode = 1;
|
||||
// else
|
||||
// cpu_pos += retsize;
|
||||
//}
|
||||
|
||||
/* 0x38 Ld aslo known as Li */
|
||||
if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Ld))) == ConvertBitToByte32(cpuPPCInit_Ld))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* the opcode. but a opcode have also normal bit that is always been set to
|
||||
* same. thuse bit are always 0 or 1
|
||||
*/
|
||||
CPU_BYTE cpuPPCInit_Addx[32] = {2,0,1,0,1,0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,0};
|
||||
|
||||
CPU_BYTE cpuPPCInit_Blr[32] = {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0};
|
||||
|
||||
|
||||
|
|
|
@ -27,22 +27,7 @@
|
|||
* value +1 and higher : who many byte we should add to cpu_pos
|
||||
*/
|
||||
|
||||
CPU_INT PPC_Addx( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
|
||||
CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch,
|
||||
CPU_INT mode)
|
||||
|
||||
{
|
||||
/*
|
||||
* ConvertBitToByte() is perfect to use to get the bit being in use from a bit array
|
||||
* GetMaskByte() is perfect if u whant known which bit have been mask out
|
||||
* see M68kopcode.c and how it use the ConvertBitToByte()
|
||||
*/
|
||||
|
||||
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||
|
||||
printf(";Add unimplement\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPU_INT PPC_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
|
||||
CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue