Author: greatlrd
Date: Wed Jan 17 18:31:47 2007
New Revision: 25496
URL:
http://svn.reactos.org/svn/reactos?rev=25496&view=rev
Log:
fixing the ppc to ia32 break, use ebx as ebp if we got to many register.
Added:
trunk/rosapps/devutils/cputointel/ConvertingProcess.c (with props)
Modified:
trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c
trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.c
trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.h
trunk/rosapps/devutils/cputointel/From/PPC/PPCopcode.c
Modified: trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/Conver…
==============================================================================
--- trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c (original)
+++ trunk/rosapps/devutils/cputointel/ConvertToIA32Process.c Wed Jan 17 18:31:47 2007
@@ -22,6 +22,7 @@
if (HowManyRegInUse > 8)
{
setup_ebp =1; /* we will use ebx as ebp */
+ stack = HowManyRegInUse * regbits;
}
@@ -36,13 +37,17 @@
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 @@
{
/* 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 @@
}
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 @@
/* 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;
Added: trunk/rosapps/devutils/cputointel/ConvertingProcess.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/Conver…
==============================================================================
--- trunk/rosapps/devutils/cputointel/ConvertingProcess.c (added)
+++ trunk/rosapps/devutils/cputointel/ConvertingProcess.c Wed Jan 17 18:31:47 2007
@@ -1,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;
+}
Propchange: trunk/rosapps/devutils/cputointel/ConvertingProcess.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/From/P…
==============================================================================
--- trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.c (original)
+++ trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.c Wed Jan 17 18:31:47 2007
@@ -59,16 +59,6 @@
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))
Modified: trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/From/P…
==============================================================================
--- trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.h (original)
+++ trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.h Wed Jan 17 18:31:47 2007
@@ -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};
Modified: trunk/rosapps/devutils/cputointel/From/PPC/PPCopcode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/From/P…
==============================================================================
--- trunk/rosapps/devutils/cputointel/From/PPC/PPCopcode.c (original)
+++ trunk/rosapps/devutils/cputointel/From/PPC/PPCopcode.c Wed Jan 17 18:31:47 2007
@@ -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,