Author: greatlrd
Date: Thu Jan 18 18:40:37 2007
New Revision: 25511
URL:
http://svn.reactos.org/svn/reactos?rev=25511&view=rev
Log:
Fixing some ppc disambler bugs. Li are not 100% test it can contain some fault.
Fixing Li bug the register for dest was wrong calctions see file OpCodePPC.txt.
fixing some meaing in ReadMe.txt
Modified:
trunk/rosapps/devutils/cputointel/From/PPC/PPC.h
trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.c
trunk/rosapps/devutils/cputointel/From/PPC/PPCBrain.h
trunk/rosapps/devutils/cputointel/From/PPC/PPCopcode.c
trunk/rosapps/devutils/cputointel/OpCodePPC.txt
trunk/rosapps/devutils/cputointel/ReadMe.txt
Modified: trunk/rosapps/devutils/cputointel/From/PPC/PPC.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/From/P…
==============================================================================
--- trunk/rosapps/devutils/cputointel/From/PPC/PPC.h (original)
+++ trunk/rosapps/devutils/cputointel/From/PPC/PPC.h Thu Jan 18 18:40:37 2007
@@ -10,14 +10,11 @@
/* here we put the prototype for the opcode api that brain need we show a example for it
*/
-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 PPC_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size,
CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
-CPU_INT PPC_Ld( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size,
CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
+CPU_INT PPC_Li( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size,
CPU_UNINT BaseAddress, CPU_UNINT cpuarch);
/* Export comment thing see m68k for example
* in dummy we do not show it, for it is diffent for each cpu
*/
-extern CPU_BYTE PPC_D[32];
-extern CPU_BYTE PPC_A[32];
-extern CPU_BYTE PPC_ds[32];
+
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 Thu Jan 18 18:40:37 2007
@@ -59,10 +59,10 @@
cpuint = GetData32Le(&cpu_buffer[cpu_pos]);
- /* 0x38 Ld aslo known as Li */
- if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Ld))) ==
ConvertBitToByte32(cpuPPCInit_Ld))
+ /* 0xE = Li*/
+ if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Li))) ==
ConvertBitToByte32(cpuPPCInit_Li))
{
- retsize = PPC_Ld( outfp, cpu_buffer, cpu_pos, cpu_size,
+ retsize = PPC_Li( outfp, cpu_buffer, cpu_pos, cpu_size,
BaseAddress, cpuarch);
if (retsize<0)
retcode = 1;
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 Thu Jan 18 18:40:37 2007
@@ -12,14 +12,17 @@
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};
-CPU_BYTE cpuPPCInit_Ld[32] =
{0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,1,1,1,0,0,0};
-CPU_BYTE cpuPPCInit_Ldu[32] =
{1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,1,1,1,0,0,0};
+/* xxxx xxxx xxxx xxxx DDD0 0000 xxxx xxDD
+ * 2222 2222 2222 2222 2222 2222 0011 1022 Li
+ */
+CPU_BYTE cpuPPCInit_Li[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,1,1,
1,0,2,2};
+
/* mask */
-CPU_BYTE PPC_D[32] =
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0};
-CPU_BYTE PPC_A[32] =
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0};
-CPU_BYTE PPC_ds[32] =
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+/*
+ * no mask we implement function getting the reg right
+ */
/* bit index
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
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 Thu Jan 18 18:40:37 2007
@@ -26,7 +26,21 @@
* value 0 : wrong opcode or not vaild opcode
* value +1 and higher : who many byte we should add to cpu_pos
*/
-
+
+/* only for ppc */
+#define PPC_GetBitArray6toA(opcode) (((opcode & 0x3) << 3) | ((opcode &
0xE000) >> 13))
+
+
+
+
+CPU_UNINT PPC_GetBitArrayBto31(CPU_UNINT opcode)
+{
+ CPU_INT x1;
+ /* FIXME make it to a macro
+ * not tested to 100% yet */
+ x1 = ((opcode & 0xFFFF0000)>>16);
+ return x1;
+}
CPU_INT PPC_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
@@ -47,23 +61,12 @@
}
-CPU_INT PPC_Ld( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
+CPU_INT PPC_Li( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
{
- CPU_UNINT formA;
- CPU_UNINT formD;
- CPU_UNINT formDS;
CPU_UNINT opcode;
opcode = GetData32Le(cpu_buffer);
- formD = (opcode & ConvertBitToByte32(PPC_D)) >> 6;
- formA = (opcode & ConvertBitToByte32(PPC_A)) >> 13;
- formDS = (opcode & ConvertBitToByte32(PPC_ds)) >> 15;
-
- if (formD != 0)
- {
- return 0;
- }
BaseAddress +=cpu_pos;
@@ -75,8 +78,8 @@
pMyBrainAnalys->op = OP_ANY_mov;
pMyBrainAnalys->type= 8 + 16; /* 8 dst reg, 16 imm */
pMyBrainAnalys->src_size = 16;
- pMyBrainAnalys->src = formDS;
- pMyBrainAnalys->dst = formA;
+ pMyBrainAnalys->src = PPC_GetBitArrayBto31(opcode);
+ pMyBrainAnalys->dst = PPC_GetBitArray6toA(opcode);
pMyBrainAnalys->memAdr=BaseAddress;
return 4;
Modified: trunk/rosapps/devutils/cputointel/OpCodePPC.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/OpCode…
==============================================================================
--- trunk/rosapps/devutils/cputointel/OpCodePPC.txt (original)
+++ trunk/rosapps/devutils/cputointel/OpCodePPC.txt Thu Jan 18 18:40:37 2007
@@ -20,14 +20,15 @@
Here how the primary opcode work
xxxx xxxx xxxx xxxx DDDS SSSS 3333 33DD
+
3 = it is the primary opcode
D = Destions register
S = Source reigters
- opcode
- ------------------------
- |bit order: 0123 45 67|
- ------- ------- ----------- ----
+ opcode
+ ------------------------
+ |bit order: 0123 45 67|
+ ------- ------- ----------- ----
34: | 0c 00 | | e1 93 | stw r31,12(r1) 0000 1100 0000 0000 1110 0001 | 1001 00 | 00
38: | 14 00 | | 01 90 | stw r0,20(r1) 0001 0100 0000 0000 0000 0001 | 1001 00 | 11
------- ------- ---------
@@ -41,8 +42,7 @@
\ /
The address offset 12 or 20
-
-
+
---------------------------------------------------------
|bit order: pos 1111 1111 1111 1111 0000 0000 0000 0000 |
| 89AB CDEF 0123 4567 89AB CDEF 0123 4567 |
Modified: trunk/rosapps/devutils/cputointel/ReadMe.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/cputointel/ReadMe…
==============================================================================
--- trunk/rosapps/devutils/cputointel/ReadMe.txt (original)
+++ trunk/rosapps/devutils/cputointel/ReadMe.txt Thu Jan 18 18:40:37 2007
@@ -2,22 +2,25 @@
The Idea
-The idea is to convert a binary file or win pe file
+The idea is to converting binary files or win pe files
from one cpu to another cpu, But it does not exists
plan to port over diffent hardware architect like
how diffent hw comucate, example x86 DMA controller
-to PPC like. It is only to convert the the binary or
-pe file to another cpu. it mean a user mode apps
-will always be ported, but if it self modify code
-it will not work. But it exists a idea to deal with
-self modify code.
+to PPC like that stuff. It is only to convert the
+binary or pe files to another cpu. it mean a user
+mode apps will always be ported, but if it self
+modify code it will not work. But it exists idea how
+to deal with self modify code.
The idea to handling self modify code
-The idea is to add a small emulator that
-runing the apps or adding a anylasuing process
-to dectect self modify code and extract it
-this is hard thing todo. almost imposible
+The idea is to add a small emulator or adding
+anaylysing process to dectect self modify code
+and extract it. This is very hard part todo, some say
+imposible, some other say almost imposble. and I say
+it is posible todo but extream hard todo. for it is
+very diffcul to dectect self modify code with a
+analysing process.
Why the name are CpuToIntel