4 #include "DummyBrain.h"
6 #include "../../misc.h"
11 * DummyBrain is example how you create you own cpu brain to translate from
12 * cpu to intel assembler, I have not add DummyBrain to the loader it is not
13 * need it in our example. When you write you own brain, it must be setup in
14 * misc.c function LoadPFileImage and PEFileStart, PEFileStart maybe does not
15 * need the brain you have writen so you do not need setup it there then.
18 * cpu_buffer : the memory buffer with loaded program we whant translate
19 * cpu_pos : the positions in the cpu_buffer
20 * cpu_size : the alloced memory size of the cpu_buffer
21 * BaseAddress : the virtual memory address we setup to use.
22 * cpuarch : the sub arch for the brain, example if it exists more one
23 * cpu with same desgin but few other opcode or extend opcode
24 * outfp : the output file pointer
34 CPU_INT
DummyBrain( CPU_BYTE
*cpu_buffer
,
37 CPU_UNINT BaseAddress
,
46 /* now we start the process */
47 while (cpu_pos
<cpu_size
)
51 /* use the GetData32Be or GetData32Le
52 to read from the memory the
53 Le is for small endian and the
55 the 32 is how many bits we should read
57 cpuint
= GetData32Be(&cpu_buffer
[cpu_pos
]);
60 if ((cpuint
- (cpuint
& GetMaskByte(cpuDummyInit_Add
))) == ConvertBitToByte(cpuDummyInit_Add
))
62 retsize
= DUMMY_Add( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
63 BaseAddress
, cpuarch
);
70 /* Found all Opcode and breakout and return no error found */
71 if (cpu_pos
>=cpu_size
)
76 /* Check if we have found a cpu opcode */
77 if (cpu_oldpos
== cpu_pos
)
81 /* no unimplement error where found so we return a msg for unknown opcode */
82 printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos
+BaseAddress
,(unsigned int)cpu_buffer
[cpu_oldpos
]);
90 /* Erorro Found break and return the error code */