mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 23:18:39 +00:00
Fixing a bug in ppc opcode Li
Fixing the memory leak bug Full implement of the Li Convert Li to my own asm langues, opcode move reg,imm Left todo is add the anyalying process and converting process, after that we can translate our frist public pe file for ppc to intel with one opcode, it must be Li svn path=/trunk/; revision=25447
This commit is contained in:
parent
c96114a82c
commit
0764ca19ac
5 changed files with 91 additions and 12 deletions
|
@ -5,6 +5,10 @@
|
||||||
#include "../../misc.h"
|
#include "../../misc.h"
|
||||||
#include "../../any_op.h"
|
#include "../../any_op.h"
|
||||||
|
|
||||||
|
/* reg r0-r31
|
||||||
|
r3 = eax
|
||||||
|
*/
|
||||||
|
|
||||||
/* cpuDummyInit_Add
|
/* cpuDummyInit_Add
|
||||||
* Input param :
|
* Input param :
|
||||||
* out : The file pointer that we write to (the output file to intel asm)
|
* out : The file pointer that we write to (the output file to intel asm)
|
||||||
|
@ -51,16 +55,22 @@ CPU_INT PPC_Ld( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
|
||||||
CPU_UNINT opcode;
|
CPU_UNINT opcode;
|
||||||
|
|
||||||
opcode = GetData32Le(cpu_buffer);
|
opcode = GetData32Le(cpu_buffer);
|
||||||
|
formD = (opcode & ConvertBitToByte32(PPC_D)) >> 6;
|
||||||
formA = (opcode & ConvertBitToByte32(PPC_A)) >> 13;
|
formA = (opcode & ConvertBitToByte32(PPC_A)) >> 13;
|
||||||
formD = (opcode & ConvertBitToByte32(PPC_D)) >> 10;
|
|
||||||
formDS = (opcode & ConvertBitToByte32(PPC_ds)) >> 15;
|
formDS = (opcode & ConvertBitToByte32(PPC_ds)) >> 15;
|
||||||
|
|
||||||
fprintf(out,"Line_0x%08x:\n",BaseAddress + cpu_pos);
|
if (formD != 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseAddress +=cpu_pos;
|
||||||
if (mode==0)
|
if (mode==0)
|
||||||
{
|
{
|
||||||
|
fprintf(out,"Line_0x%08x:\n",BaseAddress);
|
||||||
fprintf(out,"li %%r%d,%d\n",formA, formDS);
|
fprintf(out,"li %%r%d,%d\n",formA, formDS);
|
||||||
}
|
}
|
||||||
if (mode!=0)
|
else if (mode>0)
|
||||||
{
|
{
|
||||||
/* own translatons langues */
|
/* own translatons langues */
|
||||||
if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
|
if (AllocAny()!=0) /* alloc memory for pMyBrainAnalys */
|
||||||
|
@ -72,9 +82,9 @@ CPU_INT PPC_Ld( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
|
||||||
pMyBrainAnalys->src_size = 16;
|
pMyBrainAnalys->src_size = 16;
|
||||||
pMyBrainAnalys->src = formDS;
|
pMyBrainAnalys->src = formDS;
|
||||||
pMyBrainAnalys->dst = formA;
|
pMyBrainAnalys->dst = formA;
|
||||||
|
pMyBrainAnalys->memAdr=BaseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(";not full implement \n");
|
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ CPU_INT LoadPFileImage( char *infileName, char *outputfileName,
|
||||||
CPU_BYTE *cpu_buffer;
|
CPU_BYTE *cpu_buffer;
|
||||||
CPU_UNINT cpu_pos = 0;
|
CPU_UNINT cpu_pos = 0;
|
||||||
CPU_UNINT cpu_size=0;
|
CPU_UNINT cpu_size=0;
|
||||||
|
CPU_INT ret;
|
||||||
//fopen("testms.exe","RB");
|
//fopen("testms.exe","RB");
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ CPU_INT LoadPFileImage( char *infileName, char *outputfileName,
|
||||||
{
|
{
|
||||||
type=1;
|
type=1;
|
||||||
}
|
}
|
||||||
|
FreeAny();
|
||||||
fclose(outfp);
|
fclose(outfp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -120,25 +122,62 @@ CPU_INT LoadPFileImage( char *infileName, char *outputfileName,
|
||||||
if (type== 1)
|
if (type== 1)
|
||||||
{
|
{
|
||||||
if (stricmp(cpuid,"m68000"))
|
if (stricmp(cpuid,"m68000"))
|
||||||
return M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68000,outfp,mode);
|
{
|
||||||
|
ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68000,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"m68010"))
|
else if (stricmp(cpuid,"m68010"))
|
||||||
return M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68010,outfp,mode);
|
{
|
||||||
|
ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68010,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"m68020"))
|
else if (stricmp(cpuid,"m68020"))
|
||||||
return M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68020,outfp,mode);
|
{
|
||||||
|
ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68020,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"m68030"))
|
else if (stricmp(cpuid,"m68030"))
|
||||||
return M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68030,outfp,mode);
|
{
|
||||||
|
ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68030,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"m68040"))
|
else if (stricmp(cpuid,"m68040"))
|
||||||
return M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68040,outfp,mode);
|
{
|
||||||
|
ret = M68KBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,68040,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"ppc"))
|
else if (stricmp(cpuid,"ppc"))
|
||||||
return PPCBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,0,outfp,mode);
|
{
|
||||||
|
ret = PPCBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,0,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
else if (stricmp(cpuid,"arm4"))
|
else if (stricmp(cpuid,"arm4"))
|
||||||
return ARMBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,4,outfp,mode);
|
{
|
||||||
|
ret = ARMBrain(cpu_buffer,cpu_pos,cpu_size,BaseAddress,4,outfp,mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type==2)
|
if (type==2)
|
||||||
{
|
{
|
||||||
return PEFileStart(cpu_buffer, 0, BaseAddress, cpu_size, outfp, mode);
|
|
||||||
|
|
||||||
|
ret = PEFileStart(cpu_buffer, 0, BaseAddress, cpu_size, outfp, mode);
|
||||||
|
FreeAny();
|
||||||
|
fclose(outfp);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -9,12 +9,15 @@ typedef struct _BrainAnalys
|
||||||
CPU_INT type; /* 0 = source are memmory, 1 source are register */
|
CPU_INT type; /* 0 = source are memmory, 1 source are register */
|
||||||
/* 2 = dest are memmory, 4 dest are register */
|
/* 2 = dest are memmory, 4 dest are register */
|
||||||
/* 8 = source are imm */
|
/* 8 = source are imm */
|
||||||
|
|
||||||
CPU_INT src_size; /* who many bits are src not vaild for reg*/
|
CPU_INT src_size; /* who many bits are src not vaild for reg*/
|
||||||
CPU_INT dst_size; /* who many bits are dst not vaild for reg*/
|
CPU_INT dst_size; /* who many bits are dst not vaild for reg*/
|
||||||
|
|
||||||
CPU_UNINT64 src;
|
CPU_UNINT64 src;
|
||||||
CPU_UNINT64 dst;
|
CPU_UNINT64 dst;
|
||||||
|
|
||||||
|
CPU_UNINT memAdr; /* where are we in the current memory pos + baseaddress */
|
||||||
|
|
||||||
/* try translate the Adress to a name */
|
/* try translate the Adress to a name */
|
||||||
CPU_BYTE* ptr_next; /* hook next one */
|
CPU_BYTE* ptr_next; /* hook next one */
|
||||||
CPU_BYTE* ptr_prev; /* hook previus one */
|
CPU_BYTE* ptr_prev; /* hook previus one */
|
||||||
|
|
|
@ -159,6 +159,32 @@ CPU_INT AllocAny()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPU_INT FreeAny()
|
||||||
|
{
|
||||||
|
PMYBrainAnalys tmp;
|
||||||
|
tmp = (PMYBrainAnalys)pMyBrainAnalys->ptr_prev;
|
||||||
|
|
||||||
|
while (pMyBrainAnalys != NULL)
|
||||||
|
{
|
||||||
|
if (pMyBrainAnalys == NULL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pMyBrainAnalys);
|
||||||
|
|
||||||
|
if (pMyBrainAnalys != NULL)
|
||||||
|
{
|
||||||
|
printf("fail to free memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMyBrainAnalys = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,4 @@ CPU_UNINT GetData32Le(CPU_BYTE *cpu_buffer);
|
||||||
CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer);
|
CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer);
|
||||||
|
|
||||||
CPU_INT AllocAny();
|
CPU_INT AllocAny();
|
||||||
|
CPU_INT FreeAny();
|
||||||
|
|
Loading…
Reference in a new issue