9 |
|
#ifndef NEWCPU_H |
10 |
|
#define NEWCPU_H |
11 |
|
|
12 |
< |
#define SPCFLAG_STOP 2 |
13 |
< |
#define SPCFLAG_DISK 4 |
14 |
< |
#define SPCFLAG_INT 8 |
15 |
< |
#define SPCFLAG_BRK 16 |
16 |
< |
#define SPCFLAG_EXTRA_CYCLES 32 |
17 |
< |
#define SPCFLAG_TRACE 64 |
18 |
< |
#define SPCFLAG_DOTRACE 128 |
19 |
< |
#define SPCFLAG_DOINT 256 |
20 |
< |
#define SPCFLAG_BLTNASTY 512 |
21 |
< |
#define SPCFLAG_EXEC 1024 |
22 |
< |
#define SPCFLAG_MODE_CHANGE 8192 |
23 |
< |
|
24 |
< |
#ifndef SET_CFLG |
25 |
< |
|
26 |
< |
#define SET_CFLG(x) (CFLG = (x)) |
27 |
< |
#define SET_NFLG(x) (NFLG = (x)) |
28 |
< |
#define SET_VFLG(x) (VFLG = (x)) |
29 |
< |
#define SET_ZFLG(x) (ZFLG = (x)) |
30 |
< |
#define SET_XFLG(x) (XFLG = (x)) |
31 |
< |
|
32 |
< |
#define GET_CFLG CFLG |
33 |
< |
#define GET_NFLG NFLG |
34 |
< |
#define GET_VFLG VFLG |
35 |
< |
#define GET_ZFLG ZFLG |
36 |
< |
#define GET_XFLG XFLG |
37 |
< |
|
38 |
< |
#define CLEAR_CZNV do { \ |
39 |
< |
SET_CFLG (0); \ |
40 |
< |
SET_ZFLG (0); \ |
41 |
< |
SET_NFLG (0); \ |
42 |
< |
SET_VFLG (0); \ |
43 |
< |
} while (0) |
44 |
< |
|
45 |
< |
#define COPY_CARRY (SET_XFLG (GET_CFLG)) |
46 |
< |
#endif |
47 |
< |
|
12 |
> |
#include "m68k.h" |
13 |
> |
#include "readcpu.h" |
14 |
> |
#include "spcflags.h" |
15 |
> |
|
16 |
|
extern int areg_byteinc[]; |
17 |
|
extern int imm8_table[]; |
18 |
|
|
20 |
|
extern int movem_index2[256]; |
21 |
|
extern int movem_next[256]; |
22 |
|
|
55 |
– |
extern int fpp_movem_index1[256]; |
56 |
– |
extern int fpp_movem_index2[256]; |
57 |
– |
extern int fpp_movem_next[256]; |
58 |
– |
|
23 |
|
extern int broken_in; |
24 |
|
|
25 |
< |
typedef void REGPARAM2 cpuop_func (uae_u32) REGPARAM; |
25 |
> |
/* Control flow information */ |
26 |
> |
#define CFLOW_NORMAL 0 |
27 |
> |
#define CFLOW_BRANCH 1 |
28 |
> |
#define CFLOW_JUMP 2 |
29 |
> |
#define CFLOW_TRAP CFLOW_JUMP |
30 |
> |
#define CFLOW_RETURN 3 |
31 |
> |
#define CFLOW_SPCFLAGS 32 /* some spcflags are set */ |
32 |
> |
#define CFLOW_EXEC_RETURN 64 /* must exit from the execution loop */ |
33 |
> |
|
34 |
> |
#define cpuop_rettype void |
35 |
> |
#define cpuop_return(v) do { (v); return; } while (0) |
36 |
> |
|
37 |
> |
#ifdef X86_ASSEMBLY |
38 |
> |
/* This hack seems to force all register saves (pushl %reg) to be moved to the |
39 |
> |
begining of the function, thus making it possible to cpuopti to remove them |
40 |
> |
since m68k_run_1 will save those registers before calling the instruction |
41 |
> |
handler */ |
42 |
> |
# define cpuop_tag(tag) __asm__ __volatile__ ( "#cpuop_" tag ) |
43 |
> |
#else |
44 |
> |
# define cpuop_tag(tag) ; |
45 |
> |
#endif |
46 |
|
|
47 |
+ |
#define cpuop_begin() do { cpuop_tag("begin"); } while (0) |
48 |
+ |
#define cpuop_end(cflow) do { cpuop_tag("end"); cpuop_return(cflow); } while (0) |
49 |
+ |
|
50 |
+ |
typedef cpuop_rettype REGPARAM2 cpuop_func (uae_u32) REGPARAM; |
51 |
+ |
|
52 |
|
struct cputbl { |
53 |
|
cpuop_func *handler; |
54 |
< |
int specific; |
54 |
> |
uae_u16 specific; |
55 |
|
uae_u16 opcode; |
56 |
|
}; |
57 |
|
|
58 |
< |
extern void REGPARAM2 op_illg (uae_u32) REGPARAM; |
58 |
> |
extern cpuop_rettype REGPARAM2 op_illg (uae_u32) REGPARAM; |
59 |
|
|
60 |
|
typedef char flagtype; |
61 |
|
|
62 |
< |
extern struct regstruct |
63 |
< |
{ |
75 |
< |
uae_u32 regs[16]; |
76 |
< |
uaecptr usp,isp,msp; |
77 |
< |
uae_u16 sr; |
78 |
< |
flagtype t1; |
79 |
< |
flagtype t0; |
80 |
< |
flagtype s; |
81 |
< |
flagtype m; |
82 |
< |
flagtype x; |
83 |
< |
flagtype stopped; |
84 |
< |
int intmask; |
85 |
< |
|
86 |
< |
uae_u32 pc; |
87 |
< |
uae_u8 *pc_p; |
88 |
< |
uae_u8 *pc_oldp; |
62 |
> |
struct regstruct { |
63 |
> |
uae_u32 regs[16]; |
64 |
|
|
65 |
< |
uae_u32 vbr,sfc,dfc; |
66 |
< |
|
67 |
< |
double fp[8]; |
68 |
< |
uae_u32 fpcr,fpsr,fpiar; |
69 |
< |
|
70 |
< |
uae_u32 spcflags; |
71 |
< |
uae_u32 kick_mask; |
65 |
> |
uae_u32 pc; |
66 |
> |
uae_u8 * pc_p; |
67 |
> |
uae_u8 * pc_oldp; |
68 |
> |
|
69 |
> |
spcflags_t spcflags; |
70 |
> |
int intmask; |
71 |
> |
|
72 |
> |
uae_u32 vbr, sfc, dfc; |
73 |
> |
uaecptr usp, isp, msp; |
74 |
> |
uae_u16 sr; |
75 |
> |
flagtype t1; |
76 |
> |
flagtype t0; |
77 |
> |
flagtype s; |
78 |
> |
flagtype m; |
79 |
> |
flagtype x; |
80 |
> |
flagtype stopped; |
81 |
|
|
82 |
+ |
#if USE_PREFETCH_BUFFER |
83 |
|
/* Fellow sources say this is 4 longwords. That's impossible. It needs |
84 |
|
* to be at least a longword. The HRM has some cryptic comment about two |
85 |
|
* instructions being on the same longword boundary. |
86 |
|
* The way this is implemented now seems like a good compromise. |
87 |
|
*/ |
88 |
|
uae_u32 prefetch; |
89 |
< |
} regs, lastint_regs; |
89 |
> |
#endif |
90 |
> |
}; |
91 |
> |
|
92 |
> |
extern regstruct regs, lastint_regs; |
93 |
|
|
94 |
|
#define m68k_dreg(r,num) ((r).regs[(num)]) |
95 |
|
#define m68k_areg(r,num) (((r).regs + 8)[(num)]) |
104 |
|
#define GET_OPCODE (get_iword (0)) |
105 |
|
#endif |
106 |
|
|
107 |
+ |
#if USE_PREFETCH_BUFFER |
108 |
|
static __inline__ uae_u32 get_ibyte_prefetch (uae_s32 o) |
109 |
|
{ |
110 |
|
if (o > 3 || o < 0) |
127 |
|
return do_get_mem_long(®s.prefetch); |
128 |
|
return (do_get_mem_word (((uae_u16 *)®s.prefetch) + 1) << 16) | do_get_mem_word ((uae_u16 *)(regs.pc_p + 4)); |
129 |
|
} |
130 |
+ |
#endif |
131 |
|
|
132 |
|
#define m68k_incpc(o) (regs.pc_p += (o)) |
133 |
|
|
180 |
|
return r; |
181 |
|
} |
182 |
|
|
193 |
– |
#if !defined USE_COMPILER |
183 |
|
static __inline__ void m68k_setpc (uaecptr newpc) |
184 |
|
{ |
185 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
189 |
|
regs.pc = newpc; |
190 |
|
#endif |
191 |
|
} |
203 |
– |
#else |
204 |
– |
extern void m68k_setpc (uaecptr newpc); |
205 |
– |
#endif |
192 |
|
|
193 |
|
static __inline__ uaecptr m68k_getpc (void) |
194 |
|
{ |
199 |
|
#endif |
200 |
|
} |
201 |
|
|
216 |
– |
#ifdef USE_COMPILER |
217 |
– |
extern void m68k_setpc_fast (uaecptr newpc); |
218 |
– |
extern void m68k_setpc_bcc (uaecptr newpc); |
219 |
– |
extern void m68k_setpc_rte (uaecptr newpc); |
220 |
– |
#else |
202 |
|
#define m68k_setpc_fast m68k_setpc |
203 |
|
#define m68k_setpc_bcc m68k_setpc |
204 |
|
#define m68k_setpc_rte m68k_setpc |
205 |
< |
#endif |
205 |
> |
|
206 |
> |
static __inline__ void m68k_do_rts(void) |
207 |
> |
{ |
208 |
> |
m68k_setpc(get_long(m68k_areg(regs, 7))); |
209 |
> |
m68k_areg(regs, 7) += 4; |
210 |
> |
} |
211 |
> |
|
212 |
> |
static __inline__ void m68k_do_bsr(uaecptr oldpc, uae_s32 offset) |
213 |
> |
{ |
214 |
> |
m68k_areg(regs, 7) -= 4; |
215 |
> |
put_long(m68k_areg(regs, 7), oldpc); |
216 |
> |
m68k_incpc(offset); |
217 |
> |
} |
218 |
> |
|
219 |
> |
static __inline__ void m68k_do_jsr(uaecptr oldpc, uaecptr dest) |
220 |
> |
{ |
221 |
> |
m68k_areg(regs, 7) -= 4; |
222 |
> |
put_long(m68k_areg(regs, 7), oldpc); |
223 |
> |
m68k_setpc(dest); |
224 |
> |
} |
225 |
|
|
226 |
|
static __inline__ void m68k_setstopped (int stop) |
227 |
|
{ |
228 |
|
regs.stopped = stop; |
229 |
< |
if (stop) |
230 |
< |
regs.spcflags |= SPCFLAG_STOP; |
229 |
> |
/* A traced STOP instruction drops through immediately without |
230 |
> |
actually stopping. */ |
231 |
> |
if (stop && (regs.spcflags & SPCFLAG_DOTRACE) == 0) |
232 |
> |
SPCFLAGS_SET( SPCFLAG_STOP ); |
233 |
|
} |
234 |
|
|
235 |
|
extern uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp); |
241 |
|
extern void MakeFromSR (void); |
242 |
|
extern void Exception (int, uaecptr); |
243 |
|
extern void dump_counts (void); |
244 |
< |
extern void m68k_move2c (int, uae_u32 *); |
245 |
< |
extern void m68k_movec2 (int, uae_u32 *); |
244 |
> |
extern int m68k_move2c (int, uae_u32 *); |
245 |
> |
extern int m68k_movec2 (int, uae_u32 *); |
246 |
|
extern void m68k_divl (uae_u32, uae_u32, uae_u16, uaecptr); |
247 |
|
extern void m68k_mull (uae_u32, uae_u32, uae_u16); |
248 |
+ |
extern void m68k_emulop (uae_u32); |
249 |
+ |
extern void m68k_emulop_return (void); |
250 |
|
extern void init_m68k (void); |
251 |
|
extern void exit_m68k (void); |
248 |
– |
extern void m68k_go (int); |
252 |
|
extern void m68k_dumpstate (uaecptr *); |
253 |
|
extern void m68k_disasm (uaecptr, uaecptr *, int); |
254 |
|
extern void m68k_reset (void); |
255 |
|
extern void m68k_enter_debugger(void); |
256 |
+ |
extern int m68k_do_specialties(void); |
257 |
|
|
258 |
|
extern void mmu_op (uae_u32, uae_u16); |
259 |
|
|
256 |
– |
extern void fpp_opp (uae_u32, uae_u16); |
257 |
– |
extern void fdbcc_opp (uae_u32, uae_u16); |
258 |
– |
extern void fscc_opp (uae_u32, uae_u16); |
259 |
– |
extern void ftrapcc_opp (uae_u32,uaecptr); |
260 |
– |
extern void fbcc_opp (uae_u32, uaecptr, uae_u32); |
261 |
– |
extern void fsave_opp (uae_u32); |
262 |
– |
extern void frestore_opp (uae_u32); |
263 |
– |
|
264 |
– |
extern void fpu_set_integral_fpu (bool is_integral); |
265 |
– |
extern void fpu_init (void); |
266 |
– |
extern void fpu_exit (void); |
267 |
– |
extern void fpu_reset (void); |
268 |
– |
|
260 |
|
/* Opcode of faulting instruction */ |
261 |
|
extern uae_u16 last_op_for_exception_3; |
262 |
|
/* PC at fault time */ |
267 |
|
#define CPU_OP_NAME(a) op ## a |
268 |
|
|
269 |
|
/* 68020 + 68881 */ |
270 |
< |
extern struct cputbl op_smalltbl_0[]; |
270 |
> |
extern struct cputbl op_smalltbl_0_ff[]; |
271 |
|
/* 68020 */ |
272 |
< |
extern struct cputbl op_smalltbl_1[]; |
272 |
> |
extern struct cputbl op_smalltbl_1_ff[]; |
273 |
|
/* 68010 */ |
274 |
< |
extern struct cputbl op_smalltbl_2[]; |
274 |
> |
extern struct cputbl op_smalltbl_2_ff[]; |
275 |
|
/* 68000 */ |
276 |
< |
extern struct cputbl op_smalltbl_3[]; |
276 |
> |
extern struct cputbl op_smalltbl_3_ff[]; |
277 |
|
/* 68000 slow but compatible. */ |
278 |
< |
extern struct cputbl op_smalltbl_4[]; |
288 |
< |
|
289 |
< |
extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl"); |
278 |
> |
extern struct cputbl op_smalltbl_4_ff[]; |
279 |
|
|
280 |
+ |
extern void m68k_do_execute(void); |
281 |
+ |
extern void m68k_execute(void); |
282 |
+ |
|
283 |
|
#endif /* NEWCPU_H */ |