1. last move is done arm to From folder

2. remove some include in CpuToIntel.c file they are not longer need it. 


svn path=/trunk/; revision=25436
This commit is contained in:
Magnus Olsen 2007-01-13 10:39:12 +00:00
parent 40bbafca90
commit 4ffa785260
8 changed files with 144 additions and 7 deletions

View file

@ -3,9 +3,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ARM/ARM.h"
#include "From/m68k/m68k.h"
#include "From/PPC/PPC.h"
#include "misc.h"
int main(int argc, char * argv[])

View file

@ -0,0 +1,17 @@
#include "../../misc.h"
CPU_INT ARMBrain( CPU_BYTE *cpu_buffer,
CPU_UNINT cpu_pos,
CPU_UNINT cpu_size,
CPU_UNINT BaseAddress,
CPU_UNINT cpuarch,
FILE *outfp);
/* here we put the prototype for the opcode api that brain need we show a example for it */
CPU_INT ARM_(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
*/

View file

@ -0,0 +1,72 @@
#include <stdio.h>
#include <stdlib.h>
#include "ARMBrain.h"
#include "ARM.h"
#include "../../misc.h"
/* retun
* 0 : Ok
* 1 : unimplemt
* 2 : Unkonwn Opcode
* 3 : unimplement cpu
* 4 : unknown machine
*/
CPU_INT ARMBrain( CPU_BYTE *cpu_buffer,
CPU_UNINT cpu_pos,
CPU_UNINT cpu_size,
CPU_UNINT BaseAddress,
CPU_UNINT cpuarch,
FILE *outfp)
{
CPU_UNINT cpu_oldpos;
CPU_INT cpuint;
CPU_INT retcode = 0;
CPU_INT retsize;
/* now we start the process */
while (cpu_pos<cpu_size)
{
cpu_oldpos = cpu_pos;
cpuint = cpu_buffer[cpu_pos];
/* Add */
if ((cpuint - (cpuint & GetMaskByte32(cpuARMInit_))) == ConvertBitToByte32(cpuARMInit_))
{
retsize = ARM_( outfp, cpu_buffer, cpu_pos, cpu_size,
BaseAddress, cpuarch);
if (retsize<0)
retcode = 1;
else
cpu_pos += retsize;
}
/* Found all Opcode and breakout and return no error found */
if (cpu_pos >=cpu_size)
{
break;
}
/* Check if we have found a cpu opcode */
if (cpu_oldpos == cpu_pos)
{
if (retcode == 0)
{
/* no unimplement error where found so we return a msg for unknown opcode */
printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]);
retcode = 2;
}
}
/* Erorro Found ? */
if (retcode!=0)
{
/* Erorro Found break and return the error code */
break;
}
}
return retcode;
}

View file

@ -0,0 +1,12 @@
#include "../../misc.h"
/* example how setup a opcode, this opcode is 16bit long (taken from M68K)
* 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent
* thing in the opcode, example which reg so on, it can be etither 0 or 1 in
* 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 cpuARMInit_[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};

View file

@ -0,0 +1,39 @@
#include <stdio.h>
#include <stdlib.h>
#include "../../misc.h"
/* cpuDummyInit_Add
* Input param :
* out : The file pointer that we write to (the output file to intel asm)
* cpu_buffer : The memory buffer we have our binary code that we whant convert
* cpu_pos : Current positions in the cpu_buffer
* cpu_size : The memory size of the cpu_buffer
* BaseAddress : The base address you whant the binay file should run from
* cpuarch : if it exists diffent cpu from a manufactor like pentium,
* pentinum-mmx so on, use this flag to specify which type
* of cpu you whant or do not use it if it does not exists
* other or any sub model.
*
* Return value :
* value -1 : unimplement
* value 0 : wrong opcode or not vaild opcode
* value +1 and higher : who many byte we should add to cpu_pos
*/
CPU_INT ARM_( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos,
CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch)
{
/*
* 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;
}

View file

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include "misc.h"
#include "ARM/ARM.h"
#include "From/ARM/ARM.h"
#include "From/m68k/m68k.h"
#include "From/PPC/PPC.h"

View file

@ -10,8 +10,8 @@
<file>ImageLoader.c</file>
<file>misc.c</file>
<file>ARM/ARMBrain.c</file>
<file>ARM/ARMopcode.c</file>
<file>From/ARM/ARMBrain.c</file>
<file>From/ARM/ARMopcode.c</file>
<file>From/m68k/M68kBrain.c</file>
<file>From/m68k/M68kopcode.c</file>

View file

@ -7,7 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include "misc.h"
#include "ARM/ARM.h"
#include "From/ARM/ARM.h"
#include "From/m68k/m68k.h"
#include "From/PPC/PPC.h"