mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 17:14:32 +00:00
adding GetData32Be, GetData32Le for getting 4bytes from big or lite endian
start implment Ld for ppc. svn path=/trunk/; revision=25440
This commit is contained in:
parent
ad3d7fea36
commit
350c6a32c2
7 changed files with 105 additions and 3 deletions
|
@ -14,6 +14,14 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
|
||||||
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);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
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 mode);
|
||||||
|
|
||||||
/* Export comment thing see m68k for example
|
/* Export comment thing see m68k for example
|
||||||
* in dummy we do not show it, for it is diffent for each cpu
|
* 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];
|
||||||
|
|
|
@ -58,7 +58,7 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
|
||||||
{
|
{
|
||||||
cpu_oldpos = cpu_pos;
|
cpu_oldpos = cpu_pos;
|
||||||
|
|
||||||
cpuint = cpu_buffer[cpu_pos];
|
cpuint = GetData32Le(&cpu_buffer[cpu_pos]);
|
||||||
|
|
||||||
/* Add */
|
/* Add */
|
||||||
if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Addx))) == ConvertBitToByte32(cpuPPCInit_Addx))
|
if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Addx))) == ConvertBitToByte32(cpuPPCInit_Addx))
|
||||||
|
@ -71,6 +71,17 @@ CPU_INT PPCBrain( CPU_BYTE *cpu_buffer,
|
||||||
cpu_pos += retsize;
|
cpu_pos += retsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ld aslo known as Li */
|
||||||
|
if ((cpuint - (cpuint & GetMaskByte32(cpuPPCInit_Ld))) == ConvertBitToByte32(cpuPPCInit_Ld))
|
||||||
|
{
|
||||||
|
retsize = PPC_Ld( outfp, cpu_buffer, cpu_pos, cpu_size,
|
||||||
|
BaseAddress, cpuarch, mode);
|
||||||
|
if (retsize<0)
|
||||||
|
retcode = 1;
|
||||||
|
else
|
||||||
|
cpu_pos += retsize;
|
||||||
|
}
|
||||||
|
|
||||||
/* Found all Opcode and breakout and return no error found */
|
/* Found all Opcode and breakout and return no error found */
|
||||||
if (cpu_pos >=cpu_size)
|
if (cpu_pos >=cpu_size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,3 +10,18 @@
|
||||||
*/
|
*/
|
||||||
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_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_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};
|
||||||
|
|
||||||
|
|
||||||
|
/* 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};
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
|
@ -39,3 +39,31 @@ CPU_INT PPC_Addx( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
|
||||||
printf(";Add unimplement\n");
|
printf(";Add unimplement\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// stb
|
||||||
|
|
||||||
|
// li %r3, 0 : op 00 00 60 38
|
||||||
|
// li = ld
|
||||||
|
// 0000 0000 0000 0000 0100 0000 0011 1000
|
||||||
|
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 mode)
|
||||||
|
{
|
||||||
|
CPU_UNINT formA;
|
||||||
|
CPU_UNINT formD;
|
||||||
|
CPU_UNINT formDS;
|
||||||
|
CPU_UNINT opcode;
|
||||||
|
|
||||||
|
opcode = GetData32Le(cpu_buffer);
|
||||||
|
formA = (opcode & ConvertBitToByte(PPC_A)) >> 5;
|
||||||
|
formD = (opcode & ConvertBitToByte(PPC_D)) >> 10;
|
||||||
|
formDS = (opcode & ConvertBitToByte(PPC_ds)) >> 15;
|
||||||
|
|
||||||
|
if (mode==0)
|
||||||
|
{
|
||||||
|
fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(";not full implement \n");
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,13 @@ CPU_INT DummyBrain( CPU_BYTE *cpu_buffer,
|
||||||
{
|
{
|
||||||
cpu_oldpos = cpu_pos;
|
cpu_oldpos = cpu_pos;
|
||||||
|
|
||||||
cpuint = cpu_buffer[cpu_pos];
|
/* use the GetData32Be or GetData32Le
|
||||||
|
to read from the memory the
|
||||||
|
Le is for small endian and the
|
||||||
|
Be is for big endian
|
||||||
|
the 32 is how many bits we should read
|
||||||
|
*/
|
||||||
|
cpuint = GetData32Be(&cpu_buffer[cpu_pos]);
|
||||||
|
|
||||||
/* Add */
|
/* Add */
|
||||||
if ((cpuint - (cpuint & GetMaskByte(cpuDummyInit_Add))) == ConvertBitToByte(cpuDummyInit_Add))
|
if ((cpuint - (cpuint & GetMaskByte(cpuDummyInit_Add))) == ConvertBitToByte(cpuDummyInit_Add))
|
||||||
|
|
|
@ -97,6 +97,37 @@ CPU_UNINT GetMaskByte32(CPU_BYTE *bit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CPU_UNINT GetData32Le(CPU_BYTE *cpu_buffer)
|
||||||
|
{
|
||||||
|
CPU_UNINT cpuint;
|
||||||
|
CPU_UNINT split1;
|
||||||
|
CPU_UNINT split2;
|
||||||
|
CPU_UNINT split3;
|
||||||
|
CPU_UNINT split4;
|
||||||
|
|
||||||
|
cpuint = *((CPU_UNINT*) &cpu_buffer[0]);
|
||||||
|
|
||||||
|
split1 = cpu_buffer[0];
|
||||||
|
split2 = cpu_buffer[1];
|
||||||
|
split3 = cpu_buffer[2];
|
||||||
|
split4 = cpu_buffer[3];
|
||||||
|
|
||||||
|
|
||||||
|
cpuint = split4+(split3 <<8 )+(split2 <<16 )+(split1 <<24 );
|
||||||
|
|
||||||
|
return cpuint;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer)
|
||||||
|
{
|
||||||
|
CPU_UNINT cpuint;
|
||||||
|
|
||||||
|
cpuint = *((CPU_UNINT*) &cpu_buffer[0]);
|
||||||
|
|
||||||
|
return cpuint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// add no carry
|
// add no carry
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,6 @@ CPU_UNINT GetMaskByte(CPU_BYTE *bit);
|
||||||
CPU_UNINT ConvertBitToByte32(CPU_BYTE *bit);
|
CPU_UNINT ConvertBitToByte32(CPU_BYTE *bit);
|
||||||
CPU_UNINT GetMaskByte32(CPU_BYTE *bit);
|
CPU_UNINT GetMaskByte32(CPU_BYTE *bit);
|
||||||
|
|
||||||
|
CPU_UNINT GetData32Le(CPU_BYTE *cpu_buffer);
|
||||||
|
CPU_UNINT GetData32Be(CPU_BYTE *cpu_buffer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue