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


svn path=/trunk/; revision=25511
This commit is contained in:
Magnus Olsen 2007-01-18 15:40:37 +00:00
parent fd1467e3a2
commit e6cfb666ca
6 changed files with 50 additions and 44 deletions

View file

@ -10,14 +10,11 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
/* 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];

View file

@ -59,10 +59,10 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
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;

View file

@ -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

View file

@ -27,6 +27,20 @@
* 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_Blr( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
}
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 @@ CPU_INT PPC_Ld( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
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;

View file

@ -21,13 +21,14 @@ opcode Name Desciptions
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
------- ------- ---------
@ -42,7 +43,6 @@ S = Source reigters
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 |

View file

@ -2,22 +2,25 @@ CpuToIntel is a experment tools and is strict under havy devloping
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