|
|
1.1.1.3 root 1: /*
1.1 root 2: * UAE - The Un*x Amiga Emulator
1.1.1.3 root 3: *
1.1 root 4: * MC68000 emulation
5: *
6: * Copyright 1995 Bernd Schmidt
7: */
8:
1.1.1.10 root 9: #include "readcpu.h"
10: #include "machdep/m68k.h"
1.1.1.6 root 11:
12: #ifndef SET_CFLG
13:
14: #define SET_CFLG(x) (CFLG = (x))
15: #define SET_NFLG(x) (NFLG = (x))
16: #define SET_VFLG(x) (VFLG = (x))
17: #define SET_ZFLG(x) (ZFLG = (x))
18: #define SET_XFLG(x) (XFLG = (x))
19:
20: #define GET_CFLG CFLG
21: #define GET_NFLG NFLG
22: #define GET_VFLG VFLG
23: #define GET_ZFLG ZFLG
24: #define GET_XFLG XFLG
25:
26: #define CLEAR_CZNV do { \
27: SET_CFLG (0); \
28: SET_ZFLG (0); \
29: SET_NFLG (0); \
30: SET_VFLG (0); \
1.1.1.7 root 31: } while (0)
1.1.1.6 root 32:
33: #define COPY_CARRY (SET_XFLG (GET_CFLG))
34: #endif
35:
1.1.1.15! root 36: extern const int areg_byteinc[];
! 37: extern const int imm8_table[];
1.1 root 38:
39: extern int movem_index1[256];
40: extern int movem_index2[256];
41: extern int movem_next[256];
42:
43: extern int fpp_movem_index1[256];
44: extern int fpp_movem_index2[256];
45: extern int fpp_movem_next[256];
46:
47: extern int broken_in;
48:
1.1.1.4 root 49: typedef unsigned long cpuop_func (uae_u32) REGPARAM;
1.1 root 50:
51: struct cputbl {
52: cpuop_func *handler;
53: int specific;
1.1.1.3 root 54: uae_u16 opcode;
1.1 root 55: };
56:
1.1.1.4 root 57: extern unsigned long op_illg (uae_u32) REGPARAM;
1.1 root 58:
1.1.1.2 root 59: typedef char flagtype;
1.1 root 60:
1.1.1.11 root 61: /* You can set this to long double to be more accurate. However, the
62: resulting alignment issues will cost a lot of performance in some
63: apps */
64: #define USE_LONG_DOUBLE 0
65:
66: #if USE_LONG_DOUBLE
67: typedef long double fptype;
68: #else
69: typedef double fptype;
70: #endif
71:
1.1.1.3 root 72: extern struct regstruct
1.1 root 73: {
1.1.1.3 root 74: uae_u32 regs[16];
1.1.1.14 root 75: uaecptr usp,isp,msp;
1.1.1.3 root 76: uae_u16 sr;
1.1 root 77: flagtype t1;
78: flagtype t0;
79: flagtype s;
80: flagtype m;
81: flagtype x;
82: flagtype stopped;
83: int intmask;
1.1.1.3 root 84:
85: uae_u32 pc;
86: uae_u8 *pc_p;
87: uae_u8 *pc_oldp;
88:
89: uae_u32 vbr,sfc,dfc;
1.1 root 90:
1.1.1.11 root 91: fptype fp[8];
92: fptype fp_result;
93:
1.1.1.3 root 94: uae_u32 fpcr,fpsr,fpiar;
1.1.1.11 root 95: uae_u32 fpsr_highbyte;
1.1.1.3 root 96:
97: uae_u32 spcflags;
98: uae_u32 kick_mask;
1.1.1.14 root 99: uae_u32 address_space_mask;
100: uae_u16 irc, ir;
1.1.1.3 root 101:
1.1.1.14 root 102: uae_u8 panic;
103: uae_u32 panic_pc, panic_addr;
1.1 root 104: } regs, lastint_regs;
105:
1.1.1.14 root 106: STATIC_INLINE uae_u32 munge24(uae_u32 x)
107: {
108: return x & regs.address_space_mask;
109: }
110:
1.1.1.10 root 111: STATIC_INLINE void set_special (uae_u32 x)
112: {
113: regs.spcflags |= x;
114: }
115:
116: STATIC_INLINE void unset_special (uae_u32 x)
117: {
118: regs.spcflags &= ~x;
119: }
120:
1.1.1.2 root 121: #define m68k_dreg(r,num) ((r).regs[(num)])
1.1.1.4 root 122: #define m68k_areg(r,num) (((r).regs + 8)[(num)])
1.1 root 123:
1.1.1.12 root 124: STATIC_INLINE void m68k_setpc (uaecptr newpc)
125: {
126: regs.pc_p = regs.pc_oldp = get_real_address (newpc);
127: regs.pc = newpc;
128: }
129:
130: STATIC_INLINE uaecptr m68k_getpc (void)
131: {
132: return regs.pc + ((char *)regs.pc_p - (char *)regs.pc_oldp);
133: }
134:
135: STATIC_INLINE uaecptr m68k_getpc_p (uae_u8 *p)
136: {
137: return regs.pc + ((char *)p - (char *)regs.pc_oldp);
138: }
139:
1.1.1.3 root 140: #define get_ibyte(o) do_get_mem_byte((uae_u8 *)(regs.pc_p + (o) + 1))
141: #define get_iword(o) do_get_mem_word((uae_u16 *)(regs.pc_p + (o)))
142: #define get_ilong(o) do_get_mem_long((uae_u32 *)(regs.pc_p + (o)))
143:
144: #define m68k_incpc(o) (regs.pc_p += (o))
145:
146: /* These are only used by the 68020/68881 code, and therefore don't
147: * need to handle prefetch. */
1.1.1.7 root 148: STATIC_INLINE uae_u32 next_ibyte (void)
1.1 root 149: {
1.1.1.4 root 150: uae_u32 r = get_ibyte (0);
151: m68k_incpc (2);
1.1.1.2 root 152: return r;
153: }
154:
1.1.1.7 root 155: STATIC_INLINE uae_u32 next_iword (void)
1.1.1.2 root 156: {
1.1.1.4 root 157: uae_u32 r = get_iword (0);
158: m68k_incpc (2);
1.1 root 159: return r;
160: }
161:
1.1.1.7 root 162: STATIC_INLINE uae_u32 next_ilong (void)
1.1 root 163: {
1.1.1.4 root 164: uae_u32 r = get_ilong (0);
165: m68k_incpc (4);
1.1 root 166: return r;
167: }
168:
1.1.1.14 root 169: STATIC_INLINE void m68k_do_rts(void)
170: {
171: m68k_setpc(get_long(m68k_areg(regs, 7)));
172: m68k_areg(regs, 7) += 4;
173: }
174:
175: STATIC_INLINE void m68k_do_bsr(uaecptr oldpc, uae_s32 offset)
176: {
177: m68k_areg(regs, 7) -= 4;
178: put_long(m68k_areg(regs, 7), oldpc);
179: m68k_incpc(offset);
180: }
181:
182: STATIC_INLINE void m68k_do_jsr(uaecptr oldpc, uaecptr dest)
183: {
184: m68k_areg(regs, 7) -= 4;
185: put_long(m68k_areg(regs, 7), oldpc);
186: m68k_setpc(dest);
187: }
1.1 root 188:
1.1.1.7 root 189: STATIC_INLINE void m68k_setstopped (int stop)
1.1 root 190: {
191: regs.stopped = stop;
1.1.1.12 root 192: /* A traced STOP instruction drops through immediately without
193: actually stopping. */
194: if (stop && (regs.spcflags & SPCFLAG_DOTRACE) == 0)
1.1 root 195: regs.spcflags |= SPCFLAG_STOP;
196: }
197:
1.1.1.5 root 198: extern uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp);
199: extern uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp);
1.1 root 200:
1.1.1.9 root 201: extern uae_s32 ShowEA (FILE *, int reg, amodes mode, wordsizes size, char *buf);
1.1.1.2 root 202:
1.1.1.4 root 203: extern void MakeSR (void);
204: extern void MakeFromSR (void);
205: extern void Exception (int, uaecptr);
206: extern void dump_counts (void);
1.1.1.8 root 207: extern int m68k_move2c (int, uae_u32 *);
208: extern int m68k_movec2 (int, uae_u32 *);
1.1.1.3 root 209: extern void m68k_divl (uae_u32, uae_u32, uae_u16, uaecptr);
210: extern void m68k_mull (uae_u32, uae_u32, uae_u16);
1.1 root 211: extern void init_m68k (void);
1.1.1.4 root 212: extern void m68k_go (int);
1.1.1.9 root 213: extern void m68k_dumpstate (FILE *, uaecptr *);
214: extern void m68k_disasm (FILE *, uaecptr, uaecptr *, int);
1.1.1.4 root 215: extern void m68k_reset (void);
1.1.1.2 root 216:
1.1.1.3 root 217: extern void mmu_op (uae_u32, uae_u16);
1.1.1.2 root 218:
1.1.1.3 root 219: extern void fpp_opp (uae_u32, uae_u16);
220: extern void fdbcc_opp (uae_u32, uae_u16);
221: extern void fscc_opp (uae_u32, uae_u16);
222: extern void ftrapcc_opp (uae_u32,uaecptr);
223: extern void fbcc_opp (uae_u32, uaecptr, uae_u32);
224: extern void fsave_opp (uae_u32);
225: extern void frestore_opp (uae_u32);
226:
1.1.1.14 root 227: extern void exception3 (uae_u32 opcode, uaecptr addr, uaecptr fault);
228: extern void exception3i (uae_u32 opcode, uaecptr addr, uaecptr fault);
229: extern void exception2 (uaecptr addr, uaecptr fault);
230: extern void cpureset (void);
231:
232: extern void fill_prefetch_slow (void);
1.1 root 233:
1.1.1.2 root 234: #define CPU_OP_NAME(a) op ## a
235:
1.1.1.10 root 236: /* 68040 */
237: extern struct cputbl op_smalltbl_0_ff[];
1.1.1.3 root 238: /* 68020 + 68881 */
1.1.1.10 root 239: extern struct cputbl op_smalltbl_1_ff[];
1.1.1.3 root 240: /* 68020 */
1.1.1.10 root 241: extern struct cputbl op_smalltbl_2_ff[];
1.1.1.3 root 242: /* 68010 */
1.1.1.10 root 243: extern struct cputbl op_smalltbl_3_ff[];
1.1.1.3 root 244: /* 68000 */
1.1.1.10 root 245: extern struct cputbl op_smalltbl_4_ff[];
1.1.1.3 root 246: /* 68000 slow but compatible. */
1.1.1.10 root 247: extern struct cputbl op_smalltbl_5_ff[];
1.1.1.3 root 248:
249: extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl");
1.1.1.2 root 250:
1.1.1.11 root 251: #ifdef JIT
252: #else
253: #define flush_icache(X) do {} while (0)
254: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.