12 * 3 = can not open read file
13 * 4 = can not open write file
14 * 5 = can not seek to end of read file
15 * 6 = can not get the file size of the read file
16 * 7 = read file size is Zero
17 * 8 = can not alloc memory
18 * 9 = can not read file
21 CPU_INT
M68KBrain( CPU_BYTE
*cpu_buffer
,
24 CPU_UNINT BaseAddress
,
33 /* now we start the process */
34 while (cpu_pos
<cpu_size
)
38 cpuint
= cpu_buffer
[cpu_pos
];
41 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Abcd
))) == ConvertBitToByte(cpuM68kInit_Abcd
))
43 retsize
= M68k_Abcd( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
44 BaseAddress
, cpuarch
);
51 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Add
))) == ConvertBitToByte(cpuM68kInit_Add
))
53 retsize
= M68k_Add( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
54 BaseAddress
, cpuarch
);
61 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Addi
))) == ConvertBitToByte(cpuM68kInit_Addi
))
63 retsize
= M68k_Addi( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
64 BaseAddress
, cpuarch
);
71 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Addq
))) == ConvertBitToByte(cpuM68kInit_Addq
))
73 retsize
= M68k_Addq( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
74 BaseAddress
, cpuarch
);
81 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Addx
))) == ConvertBitToByte(cpuM68kInit_Addx
))
83 retsize
= M68k_Addx( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
84 BaseAddress
, cpuarch
);
91 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_And
))) == ConvertBitToByte(cpuM68kInit_And
))
93 retsize
= M68k_Add( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
94 BaseAddress
, cpuarch
);
101 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Andi
))) == ConvertBitToByte(cpuM68kInit_Andi
))
103 retsize
= M68k_Andi( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
104 BaseAddress
, cpuarch
);
111 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_AndToCCRF
))) == ConvertBitToByte(cpuM68kInit_AndToCCRF
))
113 cpuint
= cpu_buffer
[cpu_pos
+1];
114 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_AndToCCRS
))) == ConvertBitToByte(cpuM68kInit_AndToCCRS
))
117 retsize
= M68k_AndToCCR( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
118 BaseAddress
, cpuarch
);
126 cpuint
= cpu_buffer
[cpu_pos
];
131 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bhi
))) == ConvertBitToByte(cpuM68kInit_Bhi
))
133 retsize
= M68k_Bhi( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
134 BaseAddress
, cpuarch
);
142 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bls
))) == ConvertBitToByte(cpuM68kInit_Bls
))
144 retsize
= M68k_Bls( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
145 BaseAddress
, cpuarch
);
153 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bcc
))) == ConvertBitToByte(cpuM68kInit_Bcc
))
155 retsize
= M68k_Bcc( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
156 BaseAddress
, cpuarch
);
164 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bcs
))) == ConvertBitToByte(cpuM68kInit_Bcs
))
166 retsize
= M68k_Bcs( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
167 BaseAddress
, cpuarch
);
175 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bne
))) == ConvertBitToByte(cpuM68kInit_Bne
))
177 retsize
= M68k_Bne( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
178 BaseAddress
, cpuarch
);
186 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Beq
))) == ConvertBitToByte(cpuM68kInit_Beq
))
188 retsize
= M68k_Beq( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
189 BaseAddress
, cpuarch
);
197 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bvc
))) == ConvertBitToByte(cpuM68kInit_Bvc
))
199 retsize
= M68k_Bvc( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
200 BaseAddress
, cpuarch
);
208 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bvs
))) == ConvertBitToByte(cpuM68kInit_Bvs
))
210 retsize
= M68k_Bvs( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
211 BaseAddress
, cpuarch
);
219 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bpl
))) == ConvertBitToByte(cpuM68kInit_Bpl
))
221 retsize
= M68k_Bpl( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
222 BaseAddress
, cpuarch
);
230 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bmi
))) == ConvertBitToByte(cpuM68kInit_Bmi
))
232 retsize
= M68k_Bmi( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
233 BaseAddress
, cpuarch
);
241 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bge
))) == ConvertBitToByte(cpuM68kInit_Bge
))
243 retsize
= M68k_Bge( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
244 BaseAddress
, cpuarch
);
252 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Blt
))) == ConvertBitToByte(cpuM68kInit_Blt
))
254 retsize
= M68k_Blt( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
255 BaseAddress
, cpuarch
);
263 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Bgt
))) == ConvertBitToByte(cpuM68kInit_Bgt
))
265 retsize
= M68k_Bgt( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
266 BaseAddress
, cpuarch
);
274 if ((cpuint
- (cpuint
& GetMaskByte(cpuM68kInit_Ble
))) == ConvertBitToByte(cpuM68kInit_Ble
))
276 retsize
= M68k_Ble( outfp
, cpu_buffer
, cpu_pos
, cpu_size
,
277 BaseAddress
, cpuarch
);
284 /* Found all Opcode and breakout and return no error found */
285 if (cpu_pos
>=cpu_size
)
290 /* Check if we have found a cpu opcode */
291 if (cpu_oldpos
== cpu_pos
)
295 /* no unimplement error where found so we return a msg for unknown opcode */
296 printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos
+BaseAddress
,(unsigned int)cpu_buffer
[cpu_oldpos
]);
304 /* Erorro Found break and return the error code */