Mercurial > repos > blastem
annotate musashi/m68kcpu.h @ 1507:2455662378ed mame_interp
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 30 Dec 2017 18:27:06 -0800 |
parents | ded16f3d7eb4 |
children | 2e57910fd641 |
rev | line source |
---|---|
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 // license:BSD-3-Clause |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 // copyright-holders:Karl Stenerud |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 /* ========================= LICENSING & COPYRIGHT ======================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 /* |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 * MUSASHI |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 * Version 4.50 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 * A portable Motorola M680x0 processor emulation engine. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 * Copyright Karl Stenerud. All rights reserved. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 #pragma once |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 #ifndef __M68KCPU_H__ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 #define __M68KCPU_H__ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 #include "../m68k_core.h" |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 typedef struct m68000_base_device m68000_base_device; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 struct m68000_base_device { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 m68k_context c; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 uint32_t cpu_type; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 uint32_t pc; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 uint32_t ppc; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 uint32_t stopped; /* Stopped state */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 uint32_t pref_addr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 uint32_t pref_data; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 uint32_t sr_mask; /* Implemented status register bits */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 uint32_t instr_mode; /* Stores whether we are in instruction mode or group 0/1 exception mode */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 uint32_t run_mode; /* Stores whether we are processing a reset, bus error, address error, or something else */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 uint32_t s_flag; /* Supervisor */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 uint32_t m_flag; /* Master/Interrupt state */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 uint32_t x_flag; /* Extend */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 uint32_t n_flag; /* Negative */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 uint32_t not_z_flag; /* Zero, inverted for speedups */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 uint32_t v_flag; /* Overflow */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 uint32_t c_flag; /* Carry */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 uint32_t int_mask; /* I0-I2 */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
42 uint32_t t1_flag; /* Trace 1 */ |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
43 uint32_t tracing; |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 uint32_t ir; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 uint32_t cyc_bcc_notake_b; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 uint32_t cyc_bcc_notake_w; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 uint32_t cyc_dbcc_f_noexp; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 uint32_t cyc_dbcc_f_exp; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 uint32_t cyc_scc_r_true; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 uint32_t cyc_movem_w; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 uint32_t cyc_movem_l; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 uint32_t cyc_shift; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 uint32_t cyc_reset; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 void (**jump_table)(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 const uint8_t* cyc_instruction; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 const uint8_t* cyc_exception; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 }; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 /* Special interrupt acknowledge values. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 * Use these as special returns from the interrupt acknowledge callback |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 * (specified later in this header). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 /* Causes an interrupt autovector (0x18 + interrupt level) to be taken. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 * This happens in a real 68K if VPA or AVEC is asserted during an interrupt |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 * acknowledge cycle instead of DTACK. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 #define M68K_INT_ACK_AUTOVECTOR 0xffffffff |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 /* Causes the spurious interrupt vector (0x18) to be taken |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 * This happens in a real 68K if BERR is asserted during the interrupt |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 * acknowledge cycle (i.e. no devices responded to the acknowledge). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 #define M68K_INT_ACK_SPURIOUS 0xfffffffe |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 #include <limits.h> |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 #if defined(__sun__) && defined(__svr4__) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 #undef REG_SP |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 #undef REG_PC |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 #undef REG_FP |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 #endif |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 /* Check for > 32bit sizes */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 #define MAKE_INT_8(A) (int8_t)(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 #define MAKE_INT_16(A) (int16_t)(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 #define MAKE_INT_32(A) (int32_t)(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 /* ============================ GENERAL DEFINES =========================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 /* Exception Vectors handled by emulation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 #define EXCEPTION_RESET 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 #define EXCEPTION_BUS_ERROR 2 /* This one is not emulated! */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 #define EXCEPTION_ADDRESS_ERROR 3 /* This one is partially emulated (doesn't stack a proper frame yet) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 #define EXCEPTION_ILLEGAL_INSTRUCTION 4 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 #define EXCEPTION_ZERO_DIVIDE 5 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 #define EXCEPTION_CHK 6 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 #define EXCEPTION_TRAPV 7 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 #define EXCEPTION_PRIVILEGE_VIOLATION 8 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 #define EXCEPTION_TRACE 9 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 #define EXCEPTION_1010 10 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 #define EXCEPTION_1111 11 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 #define EXCEPTION_FORMAT_ERROR 14 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 #define EXCEPTION_UNINITIALIZED_INTERRUPT 15 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 #define EXCEPTION_SPURIOUS_INTERRUPT 24 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 #define EXCEPTION_INTERRUPT_AUTOVECTOR 24 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 #define EXCEPTION_TRAP_BASE 32 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 /* Function codes set by CPU during data/address bus activity */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 #define FUNCTION_CODE_USER_DATA 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 #define FUNCTION_CODE_USER_PROGRAM 2 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 #define FUNCTION_CODE_SUPERVISOR_DATA 5 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 #define FUNCTION_CODE_SUPERVISOR_PROGRAM 6 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 #define FUNCTION_CODE_CPU_SPACE 7 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 /* CPU types for deciding what to emulate */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 #define CPU_TYPE_000 (0x00000001) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 #define CPU_TYPE_008 (0x00000002) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 #define CPU_TYPE_010 (0x00000004) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 #define CPU_TYPE_EC020 (0x00000008) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 #define CPU_TYPE_020 (0x00000010) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 #define CPU_TYPE_EC030 (0x00000020) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 #define CPU_TYPE_030 (0x00000040) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 #define CPU_TYPE_EC040 (0x00000080) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 #define CPU_TYPE_LC040 (0x00000100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 #define CPU_TYPE_040 (0x00000200) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 #define CPU_TYPE_SCC070 (0x00000400) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 #define CPU_TYPE_FSCPU32 (0x00000800) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 #define CPU_TYPE_COLDFIRE (0x00001000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 /* Different ways to stop the CPU */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 #define STOP_LEVEL_STOP 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 #define STOP_LEVEL_HALT 2 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 /* Used for 68000 address error processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 #define INSTRUCTION_YES 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 #define INSTRUCTION_NO 0x08 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 #define MODE_READ 0x10 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 #define MODE_WRITE 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 #define RUN_MODE_NORMAL 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 #define RUN_MODE_BERR_AERR_RESET 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 #define M68K_CACR_IBE 0x10 // Instruction Burst Enable |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 #define M68K_CACR_CI 0x08 // Clear Instruction Cache |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 #define M68K_CACR_CEI 0x04 // Clear Entry in Instruction Cache |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 #define M68K_CACR_FI 0x02 // Freeze Instruction Cache |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 #define M68K_CACR_EI 0x01 // Enable Instruction Cache |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 /* ================================ MACROS ================================ */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 /* ---------------------------- General Macros ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 /* Bit Isolation Macros */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 #define BIT_0(A) ((A) & 0x00000001) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 #define BIT_1(A) ((A) & 0x00000002) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 #define BIT_2(A) ((A) & 0x00000004) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 #define BIT_3(A) ((A) & 0x00000008) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 #define BIT_4(A) ((A) & 0x00000010) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 #define BIT_5(A) ((A) & 0x00000020) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 #define BIT_6(A) ((A) & 0x00000040) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 #define BIT_7(A) ((A) & 0x00000080) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 #define BIT_8(A) ((A) & 0x00000100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 #define BIT_9(A) ((A) & 0x00000200) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 #define BIT_A(A) ((A) & 0x00000400) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 #define BIT_B(A) ((A) & 0x00000800) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 #define BIT_C(A) ((A) & 0x00001000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 #define BIT_D(A) ((A) & 0x00002000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 #define BIT_E(A) ((A) & 0x00004000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 #define BIT_F(A) ((A) & 0x00008000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 #define BIT_10(A) ((A) & 0x00010000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 #define BIT_11(A) ((A) & 0x00020000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 #define BIT_12(A) ((A) & 0x00040000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 #define BIT_13(A) ((A) & 0x00080000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 #define BIT_14(A) ((A) & 0x00100000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 #define BIT_15(A) ((A) & 0x00200000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 #define BIT_16(A) ((A) & 0x00400000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 #define BIT_17(A) ((A) & 0x00800000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 #define BIT_18(A) ((A) & 0x01000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 #define BIT_19(A) ((A) & 0x02000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 #define BIT_1A(A) ((A) & 0x04000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 #define BIT_1B(A) ((A) & 0x08000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 #define BIT_1C(A) ((A) & 0x10000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 #define BIT_1D(A) ((A) & 0x20000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 #define BIT_1E(A) ((A) & 0x40000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 #define BIT_1F(A) ((A) & 0x80000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 /* Get the most significant bit for specific sizes */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 #define GET_MSB_8(A) ((A) & 0x80) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 #define GET_MSB_9(A) ((A) & 0x100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 #define GET_MSB_16(A) ((A) & 0x8000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 #define GET_MSB_17(A) ((A) & 0x10000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 #define GET_MSB_32(A) ((A) & 0x80000000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 #define GET_MSB_33(A) ((A) & 0x100000000U) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 /* Isolate nibbles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 #define LOW_NIBBLE(A) ((A) & 0x0f) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 #define HIGH_NIBBLE(A) ((A) & 0xf0) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 /* These are used to isolate 8, 16, and 32 bit sizes */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 #define MASK_OUT_ABOVE_2(A) ((A) & 3) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 #define MASK_OUT_ABOVE_8(A) ((A) & 0xff) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 #define MASK_OUT_ABOVE_16(A) ((A) & 0xffff) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 #define MASK_OUT_BELOW_2(A) ((A) & ~3) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 #define MASK_OUT_BELOW_8(A) ((A) & ~0xff) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 #define MASK_OUT_BELOW_16(A) ((A) & ~0xffff) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 /* No need to mask if we are 32 bit */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 #define MASK_OUT_ABOVE_32(A) ((A) & ((uint64_t)0xffffffffU)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 #define MASK_OUT_BELOW_32(A) ((A) & ~((uint64_t)0xffffffffU)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 /* Shift & Rotate Macros. */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 #define LSL(A, C) ((A) << (C)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 #define LSR(A, C) ((A) >> (C)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 /* We have to do this because the morons at ANSI decided that shifts |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 * by >= data size are undefined. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 #define LSR_32(A, C) ((C) < 32 ? (A) >> (C) : 0) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 #define LSL_32(A, C) ((C) < 32 ? (A) << (C) : 0) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 #define LSL_32_64(A, C) ((A) << (C)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 #define LSR_32_64(A, C) ((A) >> (C)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 #define ROL_33_64(A, C) (LSL_32_64(A, C) | LSR_32_64(A, 33-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 #define ROR_33_64(A, C) (LSR_32_64(A, C) | LSL_32_64(A, 33-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 #define ROL_8(A, C) MASK_OUT_ABOVE_8(LSL(A, C) | LSR(A, 8-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 #define ROL_9(A, C) (LSL(A, C) | LSR(A, 9-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 #define ROL_16(A, C) MASK_OUT_ABOVE_16(LSL(A, C) | LSR(A, 16-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 #define ROL_17(A, C) (LSL(A, C) | LSR(A, 17-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 #define ROL_32(A, C) MASK_OUT_ABOVE_32(LSL_32(A, C) | LSR_32(A, 32-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 #define ROL_33(A, C) (LSL_32(A, C) | LSR_32(A, 33-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 #define ROR_8(A, C) MASK_OUT_ABOVE_8(LSR(A, C) | LSL(A, 8-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 #define ROR_9(A, C) (LSR(A, C) | LSL(A, 9-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 #define ROR_16(A, C) MASK_OUT_ABOVE_16(LSR(A, C) | LSL(A, 16-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 #define ROR_17(A, C) (LSR(A, C) | LSL(A, 17-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 #define ROR_32(A, C) MASK_OUT_ABOVE_32(LSR_32(A, C) | LSL_32(A, 32-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 #define ROR_33(A, C) (LSR_32(A, C) | LSL_32(A, 33-(C))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 /* ------------------------------ CPU Access ------------------------------ */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 /* Access the CPU registers */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 #define REG_DA(M) (M)->c.dregs /* easy access to data and address regs */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 #define REG_D(M) (M)->c.dregs |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 #define REG_A(M) (M)->c.aregs |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 #define REG_PPC(M) (M)->ppc |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 #define REG_PC(M) (M)->pc |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 #define REG_USP(M) (M)->c.aregs[8] |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 #define REG_ISP(M) (M)->c.aregs[7] |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 #define REG_MSP(M) (M)->c.aregs[7] |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 #define REG_SP(M) (M)->c.aregs[7] |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 /* ----------------------------- Configuration ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 /* These defines are dependant on the configuration defines in m68kconf.h */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 /* Disable certain comparisons if we're not using all CPU types */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
276 #define CPU_TYPE_IS_COLDFIRE(A) 0//((A) & (CPU_TYPE_COLDFIRE)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
278 #define CPU_TYPE_IS_040_PLUS(A) 0//((A) & (CPU_TYPE_040 | CPU_TYPE_EC040)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 #define CPU_TYPE_IS_040_LESS(A) 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
281 #define CPU_TYPE_IS_030_PLUS(A) 0//((A) & (CPU_TYPE_030 | CPU_TYPE_EC030 | CPU_TYPE_040 | CPU_TYPE_EC040)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 #define CPU_TYPE_IS_030_LESS(A) 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
284 #define CPU_TYPE_IS_020_PLUS(A) 0//((A) & (CPU_TYPE_020 | CPU_TYPE_030 | CPU_TYPE_EC030 | CPU_TYPE_040 | CPU_TYPE_EC040 | CPU_TYPE_FSCPU32 | CPU_TYPE_COLDFIRE)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 #define CPU_TYPE_IS_020_LESS(A) 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
287 #define CPU_TYPE_IS_020_VARIANT(A) 0//((A) & (CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_FSCPU32)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
289 #define CPU_TYPE_IS_EC020_PLUS(A) 0//((A) & (CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_030 | CPU_TYPE_EC030 | CPU_TYPE_040 | CPU_TYPE_EC040 | CPU_TYPE_FSCPU32 | CPU_TYPE_COLDFIRE)) |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
290 #define CPU_TYPE_IS_EC020_LESS(A) 1//((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010 | CPU_TYPE_EC020)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
292 #define CPU_TYPE_IS_010(A) 0//((A) == CPU_TYPE_010) |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
293 #define CPU_TYPE_IS_010_PLUS(A) 0//((A) & (CPU_TYPE_010 | CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_EC030 | CPU_TYPE_030 | CPU_TYPE_040 | CPU_TYPE_EC040 | CPU_TYPE_FSCPU32 | CPU_TYPE_COLDFIRE)) |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
294 #define CPU_TYPE_IS_010_LESS(A) 1//((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010)) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
296 #define CPU_TYPE_IS_000(A) 1//((A) == CPU_TYPE_000 || (A) == CPU_TYPE_008) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 /* -------------------------- EA / Operand Access ------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 /* |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 * The general instruction format follows this pattern: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 * .... XXX. .... .YYY |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 * where XXX is register X and YYY is register Y |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 /* Data Register Isolation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 #define DX(M) (REG_D(M)[((M)->ir >> 9) & 7]) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 #define DY(M) (REG_D(M)[(M)->ir & 7]) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 /* Address Register Isolation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 #define AX(M) (REG_A(M)[((M)->ir >> 9) & 7]) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 #define AY(M) (REG_A(M)[(M)->ir & 7]) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 /* Effective Address Calculations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 #define EA_AY_AI_8(M) AY(M) /* address register indirect */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 #define EA_AY_AI_16(M) EA_AY_AI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 #define EA_AY_AI_32(M) EA_AY_AI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 #define EA_AY_PI_8(M) (AY(M)++) /* postincrement (size = byte) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 #define EA_AY_PI_16(M) ((AY(M)+=2)-2) /* postincrement (size = word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 #define EA_AY_PI_32(M) ((AY(M)+=4)-4) /* postincrement (size = long) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 #define EA_AY_PD_8(M) (--AY(M)) /* predecrement (size = byte) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 #define EA_AY_PD_16(M) (AY(M)-=2) /* predecrement (size = word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 #define EA_AY_PD_32(M) (AY(M)-=4) /* predecrement (size = long) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 #define EA_AY_DI_8(M) (AY(M)+MAKE_INT_16(m68ki_read_imm_16(M))) /* displacement */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 #define EA_AY_DI_16(M) EA_AY_DI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
326 #define EA_AY_DI_32(M) EA_AY_DI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
327 #define EA_AY_IX_8(M) m68ki_get_ea_ix(M, AY(M)) /* indirect + index */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 #define EA_AY_IX_16(M) EA_AY_IX_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 #define EA_AY_IX_32(M) EA_AY_IX_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 #define EA_AX_AI_8(M) AX(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 #define EA_AX_AI_16(M) EA_AX_AI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 #define EA_AX_AI_32(M) EA_AX_AI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 #define EA_AX_PI_8(M) (AX(M)++) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 #define EA_AX_PI_16(M) ((AX(M)+=2)-2) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 #define EA_AX_PI_32(M) ((AX(M)+=4)-4) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 #define EA_AX_PD_8(M) (--AX(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 #define EA_AX_PD_16(M) (AX(M)-=2) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 #define EA_AX_PD_32(M) (AX(M)-=4) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 #define EA_AX_DI_8(M) (AX(M)+MAKE_INT_16(m68ki_read_imm_16(M))) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 #define EA_AX_DI_16(M) EA_AX_DI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 #define EA_AX_DI_32(M) EA_AX_DI_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 #define EA_AX_IX_8(M) m68ki_get_ea_ix(M, AX(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 #define EA_AX_IX_16(M) EA_AX_IX_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 #define EA_AX_IX_32(M) EA_AX_IX_8(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 #define EA_A7_PI_8(m68k) ((REG_A(m68k)[7]+=2)-2) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 #define EA_A7_PD_8(m68k) (REG_A(m68k)[7]-=2) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 #define EA_AW_8(m68k) MAKE_INT_16(m68ki_read_imm_16(m68k)) /* absolute word */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 #define EA_AW_16(m68k) EA_AW_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 #define EA_AW_32(m68k) EA_AW_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 #define EA_AL_8(m68k) m68ki_read_imm_32(m68k) /* absolute long */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 #define EA_AL_16(m68k) EA_AL_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 #define EA_AL_32(m68k) EA_AL_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 #define EA_PCDI_8(m68k) m68ki_get_ea_pcdi(m68k) /* pc indirect + displacement */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 #define EA_PCDI_16(m68k) EA_PCDI_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 #define EA_PCDI_32(m68k) EA_PCDI_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 #define EA_PCIX_8(m68k) m68ki_get_ea_pcix(m68k) /* pc indirect + index */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 #define EA_PCIX_16(m68k) EA_PCIX_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 #define EA_PCIX_32(m68k) EA_PCIX_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 #define OPER_I_8(m68k) m68ki_read_imm_8(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 #define OPER_I_16(m68k) m68ki_read_imm_16(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 #define OPER_I_32(m68k) m68ki_read_imm_32(m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
367 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 /* --------------------------- Status Register ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
371 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
372 /* Flag Calculation Macros */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 #define CFLAG_8(A) (A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 #define CFLAG_16(A) ((A)>>8) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 #define CFLAG_ADD_32(S, D, R) (((S & D) | (~R & (S | D)))>>23) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
377 #define CFLAG_SUB_32(S, D, R) (((S & R) | (~D & (S | R)))>>23) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 #define VFLAG_ADD_8(S, D, R) ((S^R) & (D^R)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
380 #define VFLAG_ADD_16(S, D, R) (((S^R) & (D^R))>>8) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 #define VFLAG_ADD_32(S, D, R) (((S^R) & (D^R))>>24) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
382 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
383 #define VFLAG_SUB_8(S, D, R) ((S^D) & (R^D)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 #define VFLAG_SUB_16(S, D, R) (((S^D) & (R^D))>>8) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 #define VFLAG_SUB_32(S, D, R) (((S^D) & (R^D))>>24) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 #define NFLAG_8(A) (A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 #define NFLAG_16(A) ((A)>>8) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 #define NFLAG_32(A) ((A)>>24) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 #define NFLAG_64(A) ((A)>>56) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 #define ZFLAG_8(A) MASK_OUT_ABOVE_8(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 #define ZFLAG_16(A) MASK_OUT_ABOVE_16(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 #define ZFLAG_32(A) MASK_OUT_ABOVE_32(A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
397 /* Flag values */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 #define NFLAG_SET 0x80 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 #define NFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
400 #define CFLAG_SET 0x100 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
401 #define CFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
402 #define XFLAG_SET 0x100 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 #define XFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 #define VFLAG_SET 0x80 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 #define VFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
406 #define ZFLAG_SET 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 #define ZFLAG_CLEAR 0xffffffff |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
408 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 #define SFLAG_SET 4 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
410 #define SFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
411 #define MFLAG_SET 2 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 #define MFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 /* Turn flag values into 1 or 0 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 #define XFLAG_AS_1(M) (((M)->x_flag>>8)&1) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 #define NFLAG_AS_1(M) (((M)->n_flag>>7)&1) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
417 #define VFLAG_AS_1(M) (((M)->v_flag>>7)&1) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 #define ZFLAG_AS_1(M) (!(M)->not_z_flag) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
419 #define CFLAG_AS_1(M) (((M)->c_flag>>8)&1) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
422 /* Conditions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 #define COND_CS(M) ((M)->c_flag&0x100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 #define COND_CC(M) (!COND_CS(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
425 #define COND_VS(M) ((M)->v_flag&0x80) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
426 #define COND_VC(M) (!COND_VS(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 #define COND_NE(M) (M)->not_z_flag |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
428 #define COND_EQ(M) (!COND_NE(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
429 #define COND_MI(M) ((M)->n_flag&0x80) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 #define COND_PL(M) (!COND_MI(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
431 #define COND_LT(M) (((M)->n_flag^(M)->v_flag)&0x80) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 #define COND_GE(M) (!COND_LT(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 #define COND_HI(M) (COND_CC(M) && COND_NE(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 #define COND_LS(M) (COND_CS(M) || COND_EQ(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 #define COND_GT(M) (COND_GE(M) && COND_NE(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 #define COND_LE(M) (COND_LT(M) || COND_EQ(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 /* Reversed conditions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 #define COND_NOT_CS(M) COND_CC(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 #define COND_NOT_CC(M) COND_CS(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 #define COND_NOT_VS(M) COND_VC(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
442 #define COND_NOT_VC(M) COND_VS(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
443 #define COND_NOT_NE(M) COND_EQ(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
444 #define COND_NOT_EQ(M) COND_NE(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
445 #define COND_NOT_MI(M) COND_PL(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
446 #define COND_NOT_PL(M) COND_MI(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
447 #define COND_NOT_LT(M) COND_GE(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
448 #define COND_NOT_GE(M) COND_LT(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
449 #define COND_NOT_HI(M) COND_LS(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
450 #define COND_NOT_LS(M) COND_HI(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
451 #define COND_NOT_GT(M) COND_LE(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
452 #define COND_NOT_LE(M) COND_GT(M) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
453 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
454 /* Not real conditions, but here for convenience */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 #define COND_XS(M) ((M)->x_flag&0x100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 #define COND_XC(M) (!COND_XS) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 /* Get the condition code register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 #define m68ki_get_ccr(M) ((COND_XS(M) >> 4) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 (COND_MI(M) >> 4) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 (COND_EQ(M) << 2) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 (COND_VS(M) >> 6) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 (COND_CS(M) >> 8)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 /* Get the status register */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
467 #define m68ki_get_sr(M) ((M)->t1_flag | \ |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 /*(M)->t0_flag |*/ \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
469 ((M)->s_flag << 11) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
470 ((M)->m_flag << 11) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 (M)->int_mask | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 m68ki_get_ccr(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
476 /* ----------------------------- Read / Write ----------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 /* Read from the current address space */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 uint8_t m68ki_read_8(m68000_base_device *m68k, uint32_t address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 uint16_t m68ki_read_16(m68000_base_device *m68k, uint32_t address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 static inline uint32_t m68ki_read_32(m68000_base_device *m68k, uint32_t address) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 return m68ki_read_16(m68k, address) << 16 | m68ki_read_16(m68k, address+2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
484 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 /*#define m68ki_read_8(M, A) m68ki_read_8_fc (M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
486 #define m68ki_read_16(M, A) m68ki_read_16_fc(M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 #define m68ki_read_32(M, A) m68ki_read_32_fc(M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA)*/ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
488 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
489 /* Write to the current data space */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
490 void m68ki_write_8(m68000_base_device *m68k, uint32_t address, uint8_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
491 void m68ki_write_16(m68000_base_device *m68k, uint32_t address, uint16_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
492 static inline void m68ki_write_32(m68000_base_device *m68k, uint32_t address, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
493 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
494 m68ki_write_16(m68k, address, value >> 16); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 m68ki_write_16(m68k, address+2, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 /* |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 #define m68ki_write_8(M, A, V) m68ki_write_8_fc (M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA, V) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 #define m68ki_write_16(M, A, V) m68ki_write_16_fc(M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA, V) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 #define m68ki_write_32(M, A, V) m68ki_write_32_fc(M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA, V) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
501 #define m68ki_write_32_pd(M, A, V) m68ki_write_32_pd_fc(M, A, (M)->s_flag | FUNCTION_CODE_USER_DATA, V)*/ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
503 /* map read immediate 8 to read immediate 16 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
504 #define m68ki_read_imm_8(M) MASK_OUT_ABOVE_8(m68ki_read_imm_16(M)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
506 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
507 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 /* =============================== PROTOTYPES ============================= */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
509 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
511 union fp_reg |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
512 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
513 uint64_t i; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
514 double f; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
515 }; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
516 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
517 void m68ki_exception_interrupt(m68000_base_device *m68k, uint32_t int_level); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
518 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
519 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
520 extern const uint8_t m68ki_shift_8_table[]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 extern const uint16_t m68ki_shift_16_table[]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 extern const uint32_t m68ki_shift_32_table[]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
523 extern const uint8_t m68ki_exception_cycle_table[][256]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
524 extern const uint8_t m68ki_ea_idx_cycle_table[]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
525 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
526 /* Read data immediately after the program counter */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
527 static inline uint32_t m68ki_read_imm_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 static inline uint32_t m68ki_read_imm_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
530 /* Write data with specific function code */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
531 static inline void m68ki_write_8_fc (m68000_base_device *m68k, uint32_t address, uint32_t fc, uint32_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
532 static inline void m68ki_write_16_fc(m68000_base_device *m68k, uint32_t address, uint32_t fc, uint32_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
533 static inline void m68ki_write_32_fc(m68000_base_device *m68k, uint32_t address, uint32_t fc, uint32_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
534 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
535 /* Indexed and PC-relative ea fetching */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
536 static inline uint32_t m68ki_get_ea_pcdi(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
537 static inline uint32_t m68ki_get_ea_pcix(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
538 static inline uint32_t m68ki_get_ea_ix(m68000_base_device *m68k, uint32_t An); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
539 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
540 /* Operand fetching */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
541 static inline uint32_t OPER_AY_AI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
542 static inline uint32_t OPER_AY_AI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
543 static inline uint32_t OPER_AY_AI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
544 static inline uint32_t OPER_AY_PI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
545 static inline uint32_t OPER_AY_PI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
546 static inline uint32_t OPER_AY_PI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
547 static inline uint32_t OPER_AY_PD_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
548 static inline uint32_t OPER_AY_PD_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
549 static inline uint32_t OPER_AY_PD_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
550 static inline uint32_t OPER_AY_DI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
551 static inline uint32_t OPER_AY_DI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
552 static inline uint32_t OPER_AY_DI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
553 static inline uint32_t OPER_AY_IX_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
554 static inline uint32_t OPER_AY_IX_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
555 static inline uint32_t OPER_AY_IX_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
556 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
557 static inline uint32_t OPER_AX_AI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
558 static inline uint32_t OPER_AX_AI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
559 static inline uint32_t OPER_AX_AI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
560 static inline uint32_t OPER_AX_PI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
561 static inline uint32_t OPER_AX_PI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
562 static inline uint32_t OPER_AX_PI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
563 static inline uint32_t OPER_AX_PD_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
564 static inline uint32_t OPER_AX_PD_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
565 static inline uint32_t OPER_AX_PD_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
566 static inline uint32_t OPER_AX_DI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
567 static inline uint32_t OPER_AX_DI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
568 static inline uint32_t OPER_AX_DI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
569 static inline uint32_t OPER_AX_IX_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
570 static inline uint32_t OPER_AX_IX_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
571 static inline uint32_t OPER_AX_IX_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
572 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
573 static inline uint32_t OPER_A7_PI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
574 static inline uint32_t OPER_A7_PD_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
575 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
576 static inline uint32_t OPER_AW_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
577 static inline uint32_t OPER_AW_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
578 static inline uint32_t OPER_AW_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
579 static inline uint32_t OPER_AL_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
580 static inline uint32_t OPER_AL_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
581 static inline uint32_t OPER_AL_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
582 static inline uint32_t OPER_PCDI_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
583 static inline uint32_t OPER_PCDI_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
584 static inline uint32_t OPER_PCDI_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
585 static inline uint32_t OPER_PCIX_8(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
586 static inline uint32_t OPER_PCIX_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
587 static inline uint32_t OPER_PCIX_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
588 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
589 /* Stack operations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
590 static inline void m68ki_push_16(m68000_base_device *m68k, uint32_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
591 static inline void m68ki_push_32(m68000_base_device *m68k, uint32_t value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
592 static inline uint32_t m68ki_pull_16(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
593 static inline uint32_t m68ki_pull_32(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
594 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
595 /* Program flow operations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
596 static inline void m68ki_jump(m68000_base_device *m68k, uint32_t new_pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
597 static inline void m68ki_jump_vector(m68000_base_device *m68k, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 static inline void m68ki_branch_8(m68000_base_device *m68k, uint32_t offset); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
599 static inline void m68ki_branch_16(m68000_base_device *m68k, uint32_t offset); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
600 static inline void m68ki_branch_32(m68000_base_device *m68k, uint32_t offset); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
601 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
602 /* Status register operations. */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
603 static inline void m68ki_set_s_flag(m68000_base_device *m68k, uint32_t value); /* Only bit 2 of value should be set (i.e. 4 or 0) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 static inline void m68ki_set_sm_flag(m68000_base_device *m68k, uint32_t value); /* only bits 1 and 2 of value should be set */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
605 static inline void m68ki_set_ccr(m68000_base_device *m68k, uint32_t value); /* set the condition code register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
606 static inline void m68ki_set_sr(m68000_base_device *m68k, uint32_t value); /* set the status register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
607 static inline void m68ki_set_sr_noint(m68000_base_device *m68k, uint32_t value); /* set the status register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
608 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
609 /* Exception processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
610 static inline uint32_t m68ki_init_exception(m68000_base_device *m68k); /* Initial exception processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
611 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
612 static inline void m68ki_stack_frame_3word(m68000_base_device *m68k, uint32_t pc, uint32_t sr); /* Stack various frame types */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
613 static inline void m68ki_stack_frame_buserr(m68000_base_device *m68k, uint32_t sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
614 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
615 static inline void m68ki_stack_frame_0000(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
616 static inline void m68ki_stack_frame_0001(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
617 static inline void m68ki_stack_frame_0010(m68000_base_device *m68k, uint32_t sr, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
618 static inline void m68ki_stack_frame_1000(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
619 static inline void m68ki_stack_frame_1010(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
620 static inline void m68ki_stack_frame_1011(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
621 static inline void m68ki_stack_frame_0111(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address, uint8_t in_mmu); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
622 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
623 static inline void m68ki_exception_trap(m68000_base_device *m68k, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
624 static inline void m68ki_exception_trapN(m68000_base_device *m68k, uint32_t vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
625 static inline void m68ki_exception_trace(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
626 static inline void m68ki_exception_privilege_violation(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
627 static inline void m68ki_exception_1010(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
628 static inline void m68ki_exception_1111(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
629 static inline void m68ki_exception_illegal(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
630 static inline void m68ki_exception_format_error(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
631 static inline void m68ki_exception_address_error(m68000_base_device *m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
632 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
633 static inline void m68ki_check_interrupts(m68000_base_device *m68k); /* ASG: check for interrupts */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
634 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
635 /* quick disassembly (used for logging) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
636 char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
637 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
638 void m68k_cpu_execute(m68000_base_device *this); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
639 void m68k_reset_cpu(m68000_base_device *this); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
640 void m68k_init_cpu_m68000(m68000_base_device *this); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
641 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
642 #define m68ki_trace_t0(M) |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
643 #define m68ki_trace_t1(m68k) m68k->tracing = m68k->t1_flag |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
644 /* Clear all tracing */ |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
645 #define m68ki_clear_trace(m68k) m68k->tracing = 0 |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
646 /* Cause a trace exception if we are tracing */ |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
647 #define m68ki_exception_if_trace(m68k) if(m68k->tracing) m68ki_exception_trace(m68k) |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
648 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
649 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
650 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
651 /* =========================== UTILITY FUNCTIONS ========================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
652 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
653 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
654 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
655 /* Special call to simulate undocumented 68k behavior when move.l with a |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
656 * predecrement destination mode is executed. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
657 * A real 68k first writes the high word to [address+2], and then writes the |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
658 * low word to [address]. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
659 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
660 static inline void m68kx_write_memory_32_pd(m68000_base_device *m68k, unsigned int address, unsigned int value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
661 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
662 m68ki_write_16(m68k, address, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
663 m68ki_write_16(m68k, address, value >> 16); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
664 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
665 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
666 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
667 /* ---------------------------- Read Immediate ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
668 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
669 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
670 /* Handles all immediate reads, does address error check, function code setting, |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
671 * and prefetching if they are enabled in m68kconf.h |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
672 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
673 static inline uint32_t m68ki_read_imm_16(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
674 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
675 uint32_t result; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
676 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
677 if(REG_PC(m68k) != m68k->pref_addr) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
678 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
679 m68k->pref_data = m68ki_read_16(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
680 m68k->pref_addr = REG_PC(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
681 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
682 result = MASK_OUT_ABOVE_16(m68k->pref_data); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
683 REG_PC(m68k) += 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
684 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
685 return result; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
686 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
687 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
688 static inline uint32_t m68ki_read_imm_32(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
689 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
690 uint32_t temp_val; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
691 if(REG_PC(m68k) != m68k->pref_addr) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
692 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
693 m68k->pref_addr = REG_PC(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
694 m68k->pref_data = m68ki_read_16(m68k, m68k->pref_addr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
695 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
696 temp_val = MASK_OUT_ABOVE_16(m68k->pref_data); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
697 REG_PC(m68k) += 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
698 m68k->pref_addr = REG_PC(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
699 m68k->pref_data = m68ki_read_16(m68k, m68k->pref_addr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
700 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
701 temp_val = MASK_OUT_ABOVE_32((temp_val << 16) | MASK_OUT_ABOVE_16(m68k->pref_data)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
702 REG_PC(m68k) += 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
703 m68k->pref_data = m68ki_read_16(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
704 m68k->pref_addr = REG_PC(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
705 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
706 return temp_val; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
707 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
708 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
709 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
710 /* --------------------- Effective Address Calculation -------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
711 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
712 /* The program counter relative addressing modes cause operands to be |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
713 * retrieved from program space, not data space. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
714 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
715 static inline uint32_t m68ki_get_ea_pcdi(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
716 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 uint32_t old_pc = REG_PC(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
718 return old_pc + MAKE_INT_16(m68ki_read_imm_16(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
719 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
720 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
721 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
722 static inline uint32_t m68ki_get_ea_pcix(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
723 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
724 return m68ki_get_ea_ix(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
725 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
726 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
727 /* Indexed addressing modes are encoded as follows: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
728 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
729 * Base instruction format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
730 * F E D C B A 9 8 7 6 | 5 4 3 | 2 1 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
731 * x x x x x x x x x x | 1 1 0 | BASE REGISTER (An) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
733 * Base instruction format for destination EA in move instructions: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
734 * F E D C | B A 9 | 8 7 6 | 5 4 3 2 1 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
735 * x x x x | BASE REG | 1 1 0 | X X X X X X (An) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
736 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
737 * Brief extension format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
738 * F | E D C | B | A 9 | 8 | 7 6 5 4 3 2 1 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 * D/A | REGISTER | W/L | SCALE | 0 | DISPLACEMENT |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
740 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
741 * Full extension format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
742 * F E D C B A 9 8 7 6 5 4 3 2 1 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
743 * D/A | REGISTER | W/L | SCALE | 1 | BS | IS | BD SIZE | 0 | I/IS |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
744 * BASE DISPLACEMENT (0, 16, 32 bit) (bd) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
745 * OUTER DISPLACEMENT (0, 16, 32 bit) (od) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
746 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
747 * D/A: 0 = Dn, 1 = An (Xn) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
748 * W/L: 0 = W (sign extend), 1 = L (.SIZE) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
749 * SCALE: 00=1, 01=2, 10=4, 11=8 (*SCALE) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
750 * BS: 0=add base reg, 1=suppress base reg (An suppressed) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
751 * IS: 0=add index, 1=suppress index (Xn suppressed) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
752 * BD SIZE: 00=reserved, 01=NULL, 10=Word, 11=Long (size of bd) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
753 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
754 * IS I/IS Operation |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
755 * 0 000 No Memory Indirect |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
756 * 0 001 indir prex with null outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
757 * 0 010 indir prex with word outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
758 * 0 011 indir prex with long outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
759 * 0 100 reserved |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
760 * 0 101 indir postx with null outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
761 * 0 110 indir postx with word outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
762 * 0 111 indir postx with long outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
763 * 1 000 no memory indirect |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
764 * 1 001 mem indir with null outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
765 * 1 010 mem indir with word outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
766 * 1 011 mem indir with long outer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
767 * 1 100-111 reserved |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
768 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
769 static inline uint32_t m68ki_get_ea_ix(m68000_base_device *m68k, uint32_t An) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
770 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
771 /* An = base register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
772 uint32_t extension = m68ki_read_imm_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
773 uint32_t Xn = 0; /* Index register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
774 uint32_t bd = 0; /* Base Displacement */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
775 uint32_t od = 0; /* Outer Displacement */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
776 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
777 /* Calculate index */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
778 Xn = REG_DA(m68k)[extension>>12]; /* Xn */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
779 if(!BIT_B(extension)) /* W/L */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 Xn = MAKE_INT_16(Xn); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
781 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
782 /* Add base register and displacement and return */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
783 return An + Xn + MAKE_INT_8(extension); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
784 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
785 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
786 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
787 /* Fetch operands */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 static inline uint32_t OPER_AY_AI_8(m68000_base_device *m68k) {uint32_t ea = EA_AY_AI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
789 static inline uint32_t OPER_AY_AI_16(m68000_base_device *m68k) {uint32_t ea = EA_AY_AI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
790 static inline uint32_t OPER_AY_AI_32(m68000_base_device *m68k) {uint32_t ea = EA_AY_AI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
791 static inline uint32_t OPER_AY_PI_8(m68000_base_device *m68k) {uint32_t ea = EA_AY_PI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
792 static inline uint32_t OPER_AY_PI_16(m68000_base_device *m68k) {uint32_t ea = EA_AY_PI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
793 static inline uint32_t OPER_AY_PI_32(m68000_base_device *m68k) {uint32_t ea = EA_AY_PI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
794 static inline uint32_t OPER_AY_PD_8(m68000_base_device *m68k) {uint32_t ea = EA_AY_PD_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
795 static inline uint32_t OPER_AY_PD_16(m68000_base_device *m68k) {uint32_t ea = EA_AY_PD_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
796 static inline uint32_t OPER_AY_PD_32(m68000_base_device *m68k) {uint32_t ea = EA_AY_PD_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
797 static inline uint32_t OPER_AY_DI_8(m68000_base_device *m68k) {uint32_t ea = EA_AY_DI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
798 static inline uint32_t OPER_AY_DI_16(m68000_base_device *m68k) {uint32_t ea = EA_AY_DI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
799 static inline uint32_t OPER_AY_DI_32(m68000_base_device *m68k) {uint32_t ea = EA_AY_DI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
800 static inline uint32_t OPER_AY_IX_8(m68000_base_device *m68k) {uint32_t ea = EA_AY_IX_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
801 static inline uint32_t OPER_AY_IX_16(m68000_base_device *m68k) {uint32_t ea = EA_AY_IX_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
802 static inline uint32_t OPER_AY_IX_32(m68000_base_device *m68k) {uint32_t ea = EA_AY_IX_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
803 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
804 static inline uint32_t OPER_AX_AI_8(m68000_base_device *m68k) {uint32_t ea = EA_AX_AI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
805 static inline uint32_t OPER_AX_AI_16(m68000_base_device *m68k) {uint32_t ea = EA_AX_AI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
806 static inline uint32_t OPER_AX_AI_32(m68000_base_device *m68k) {uint32_t ea = EA_AX_AI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
807 static inline uint32_t OPER_AX_PI_8(m68000_base_device *m68k) {uint32_t ea = EA_AX_PI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
808 static inline uint32_t OPER_AX_PI_16(m68000_base_device *m68k) {uint32_t ea = EA_AX_PI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
809 static inline uint32_t OPER_AX_PI_32(m68000_base_device *m68k) {uint32_t ea = EA_AX_PI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
810 static inline uint32_t OPER_AX_PD_8(m68000_base_device *m68k) {uint32_t ea = EA_AX_PD_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
811 static inline uint32_t OPER_AX_PD_16(m68000_base_device *m68k) {uint32_t ea = EA_AX_PD_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
812 static inline uint32_t OPER_AX_PD_32(m68000_base_device *m68k) {uint32_t ea = EA_AX_PD_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
813 static inline uint32_t OPER_AX_DI_8(m68000_base_device *m68k) {uint32_t ea = EA_AX_DI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
814 static inline uint32_t OPER_AX_DI_16(m68000_base_device *m68k) {uint32_t ea = EA_AX_DI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
815 static inline uint32_t OPER_AX_DI_32(m68000_base_device *m68k) {uint32_t ea = EA_AX_DI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
816 static inline uint32_t OPER_AX_IX_8(m68000_base_device *m68k) {uint32_t ea = EA_AX_IX_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
817 static inline uint32_t OPER_AX_IX_16(m68000_base_device *m68k) {uint32_t ea = EA_AX_IX_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
818 static inline uint32_t OPER_AX_IX_32(m68000_base_device *m68k) {uint32_t ea = EA_AX_IX_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
819 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
820 static inline uint32_t OPER_A7_PI_8(m68000_base_device *m68k) {uint32_t ea = EA_A7_PI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
821 static inline uint32_t OPER_A7_PD_8(m68000_base_device *m68k) {uint32_t ea = EA_A7_PD_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
822 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
823 static inline uint32_t OPER_AW_8(m68000_base_device *m68k) {uint32_t ea = EA_AW_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
824 static inline uint32_t OPER_AW_16(m68000_base_device *m68k) {uint32_t ea = EA_AW_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
825 static inline uint32_t OPER_AW_32(m68000_base_device *m68k) {uint32_t ea = EA_AW_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
826 static inline uint32_t OPER_AL_8(m68000_base_device *m68k) {uint32_t ea = EA_AL_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
827 static inline uint32_t OPER_AL_16(m68000_base_device *m68k) {uint32_t ea = EA_AL_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
828 static inline uint32_t OPER_AL_32(m68000_base_device *m68k) {uint32_t ea = EA_AL_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
829 static inline uint32_t OPER_PCDI_8(m68000_base_device *m68k) {uint32_t ea = EA_PCDI_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
830 static inline uint32_t OPER_PCDI_16(m68000_base_device *m68k) {uint32_t ea = EA_PCDI_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
831 static inline uint32_t OPER_PCDI_32(m68000_base_device *m68k) {uint32_t ea = EA_PCDI_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
832 static inline uint32_t OPER_PCIX_8(m68000_base_device *m68k) {uint32_t ea = EA_PCIX_8(m68k); return m68ki_read_8(m68k, ea); } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
833 static inline uint32_t OPER_PCIX_16(m68000_base_device *m68k) {uint32_t ea = EA_PCIX_16(m68k); return m68ki_read_16(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
834 static inline uint32_t OPER_PCIX_32(m68000_base_device *m68k) {uint32_t ea = EA_PCIX_32(m68k); return m68ki_read_32(m68k, ea);} |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
835 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
836 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
837 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
838 /* ---------------------------- Stack Functions --------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
839 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
840 /* Push/pull data from the stack */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
841 static inline void m68ki_push_16(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
842 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
843 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
844 m68ki_write_16(m68k, REG_SP(m68k), value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
845 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
846 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
847 static inline void m68ki_push_32(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
848 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
849 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
850 m68ki_write_32(m68k, REG_SP(m68k), value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
851 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
852 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
853 static inline uint32_t m68ki_pull_16(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
854 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
855 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
856 return m68ki_read_16(m68k, REG_SP(m68k)-2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
857 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
858 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
859 static inline uint32_t m68ki_pull_32(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
860 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
861 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
862 return m68ki_read_32(m68k, REG_SP(m68k)-4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
863 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
864 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
865 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
866 /* Increment/decrement the stack as if doing a push/pull but |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
867 * don't do any memory access. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
868 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
869 static inline void m68ki_fake_push_16(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
870 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
871 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
872 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
873 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
874 static inline void m68ki_fake_push_32(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
875 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
876 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
877 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
878 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
879 static inline void m68ki_fake_pull_16(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
880 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
881 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
882 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
883 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
884 static inline void m68ki_fake_pull_32(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
885 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
886 REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
887 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
888 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
889 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
890 /* ----------------------------- Program Flow ----------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
891 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
892 /* Jump to a new program location or vector. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
893 * These functions will also call the pc_changed callback if it was enabled |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
894 * in m68kconf.h. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
895 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
896 static inline void m68ki_jump(m68000_base_device *m68k, uint32_t new_pc) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
897 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
898 REG_PC(m68k) = new_pc; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
899 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
900 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
901 static inline void m68ki_jump_vector(m68000_base_device *m68k, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
902 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
903 REG_PC(m68k) = (vector<<2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
904 REG_PC(m68k) = m68ki_read_32(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
905 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
906 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
907 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
908 /* Branch to a new memory location. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
909 * The 32-bit branch will call pc_changed if it was enabled in m68kconf.h. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
910 * So far I've found no problems with not calling pc_changed for 8 or 16 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
911 * bit branches. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
912 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
913 static inline void m68ki_branch_8(m68000_base_device *m68k, uint32_t offset) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
914 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
915 REG_PC(m68k) += MAKE_INT_8(offset); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
916 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
917 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
918 static inline void m68ki_branch_16(m68000_base_device *m68k, uint32_t offset) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
919 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
920 REG_PC(m68k) += MAKE_INT_16(offset); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
921 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
922 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
923 static inline void m68ki_branch_32(m68000_base_device *m68k, uint32_t offset) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
924 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
925 REG_PC(m68k) += offset; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
926 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
927 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
928 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
929 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
930 /* ---------------------------- Status Register --------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
931 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
932 /* Set the S flag and change the active stack pointer. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
933 * Note that value MUST be 4 or 0. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
934 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
935 static inline void m68ki_set_s_flag(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
936 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
937 /* Backup the old stack pointer */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
938 uint32_t old = REG_SP(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
939 //REG_SP_BASE(m68k)[m68k->s_flag | ((m68k->s_flag>>1) & m68k->m_flag)] = REG_SP(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
940 /* Set the S flag */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
941 if (value != m68k->s_flag) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
942 m68k->s_flag = value; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
943 /* Set the new stack pointer */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
944 REG_SP(m68k) = REG_USP(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
945 REG_USP(m68k) = old; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
946 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
947 //REG_SP(m68k) = REG_SP_BASE(m68k)[m68k->s_flag | ((m68k->s_flag>>1) & m68k->m_flag)]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
948 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
949 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
950 /* Set the S and M flags and change the active stack pointer. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
951 * Note that value MUST be 0, 2, 4, or 6 (bit2 = S, bit1 = M). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
952 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
953 static inline void m68ki_set_sm_flag(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
954 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
955 m68ki_set_s_flag(m68k, value & 4); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
956 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
957 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
958 /* Set the S and M flags. Don't touch the stack pointer. */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
959 static inline void m68ki_set_sm_flag_nosp(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
960 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
961 /* Set the S and M flags */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
962 m68k->s_flag = value & SFLAG_SET; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
963 //m68k->m_flag = value & MFLAG_SET; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
964 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
965 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
966 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
967 /* Set the condition code register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
968 static inline void m68ki_set_ccr(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
969 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
970 m68k->x_flag = BIT_4(value) << 4; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
971 m68k->n_flag = BIT_3(value) << 4; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
972 m68k->not_z_flag = !BIT_2(value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
973 m68k->v_flag = BIT_1(value) << 6; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
974 m68k->c_flag = BIT_0(value) << 8; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
975 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
976 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
977 /* Set the status register but don't check for interrupts */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
978 static inline void m68ki_set_sr_noint(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
979 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
980 /* Mask out the "unimplemented" bits */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
981 value &= m68k->sr_mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
982 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
983 /* Now set the status register */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
984 m68k->t1_flag = BIT_F(value); |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
985 //m68k->t0_flag = BIT_E(value); |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
986 m68k->int_mask = value & 0x0700; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
987 m68k->c.target_cycle = m68k->c.current_cycle; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
988 m68ki_set_ccr(m68k, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
989 m68ki_set_sm_flag(m68k, (value >> 11) & 6); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
990 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
991 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
992 /* Set the status register but don't check for interrupts nor |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
993 * change the stack pointer |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
994 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
995 static inline void m68ki_set_sr_noint_nosp(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
996 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
997 /* Mask out the "unimplemented" bits */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
998 value &= m68k->sr_mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
999 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1000 /* Now set the status register */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
1001 m68k->t1_flag = BIT_F(value); |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
1002 //m68k->t0_flag = BIT_E(value); |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1003 m68k->int_mask = value & 0x0700; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1004 m68k->c.target_cycle = m68k->c.current_cycle; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1005 m68ki_set_ccr(m68k, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1006 m68ki_set_sm_flag_nosp(m68k, (value >> 11) & 6); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1007 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1008 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1009 /* Set the status register and check for interrupts */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1010 static inline void m68ki_set_sr(m68000_base_device *m68k, uint32_t value) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1011 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1012 m68ki_set_sr_noint(m68k, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1013 m68ki_check_interrupts(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1014 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1015 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1016 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1017 /* ------------------------- Exception Processing ------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1018 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1019 /* Initiate exception processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1020 static inline uint32_t m68ki_init_exception(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1021 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1022 /* Save the old status register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1023 uint32_t sr = m68ki_get_sr(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1024 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1025 /* Turn off trace flag, clear pending traces */ |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
1026 m68k->t1_flag = 0;//m68k->t0_flag = 0; |
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
1027 m68ki_clear_trace(m68k); |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1028 /* Enter supervisor mode */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1029 m68ki_set_s_flag(m68k, SFLAG_SET); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1030 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1031 return sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1032 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1033 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1034 /* 3 word stack frame (68000 only) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1035 static inline void m68ki_stack_frame_3word(m68000_base_device *m68k, uint32_t pc, uint32_t sr) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1036 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1037 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1038 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1039 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1040 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1041 /* Format 0 stack frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1042 * This is the standard stack frame for 68010+. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1043 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1044 static inline void m68ki_stack_frame_0000(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1045 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1046 /* Stack a 3-word frame if we are 68000 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1047 if(m68k->cpu_type == CPU_TYPE_000 || m68k->cpu_type == CPU_TYPE_008) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1048 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1049 m68ki_stack_frame_3word(m68k, pc, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1050 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1051 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1052 m68ki_push_16(m68k, vector<<2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1053 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1054 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1055 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1056 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1057 /* Format 1 stack frame (68020). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1058 * For 68020, this is the 4 word throwaway frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1059 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1060 static inline void m68ki_stack_frame_0001(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1061 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1062 m68ki_push_16(m68k, 0x1000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1063 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1064 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1065 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1066 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1067 /* Format 2 stack frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1068 * This is used only by 68020 for trap exceptions. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1069 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1070 static inline void m68ki_stack_frame_0010(m68000_base_device *m68k, uint32_t sr, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1071 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1072 m68ki_push_32(m68k, REG_PPC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1073 m68ki_push_16(m68k, 0x2000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1074 m68ki_push_32(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1075 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1076 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1077 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1078 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1079 /* Bus error stack frame (68000 only). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1080 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1081 static inline void m68ki_stack_frame_buserr(m68000_base_device *m68k, uint32_t sr) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1082 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1083 m68ki_push_32(m68k, REG_PC(m68k)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1084 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1085 m68ki_push_16(m68k, m68k->ir); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1086 m68ki_push_32(m68k, 0/*m68k->aerr_address*/); /* access address */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1087 /* 0 0 0 0 0 0 0 0 0 0 0 R/W I/N FC |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1088 * R/W 0 = write, 1 = read |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1089 * I/N 0 = instruction, 1 = not |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1090 * FC 3-bit function code |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1091 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1092 m68ki_push_16(m68k, 0/*m68k->aerr_write_mode | m68k->instr_mode | m68k->aerr_fc*/); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1093 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1094 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1095 /* Format 8 stack frame (68010). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1096 * 68010 only. This is the 29 word bus/address error frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1097 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1098 static inline void m68ki_stack_frame_1000(m68000_base_device *m68k, uint32_t pc, uint32_t sr, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1099 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1100 /* VERSION |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1101 * NUMBER |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1102 * INTERNAL INFORMATION, 16 WORDS |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1103 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1104 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1105 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1106 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1107 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1108 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1109 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1110 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1111 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1112 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1113 /* INSTRUCTION INPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1114 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1115 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1116 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1117 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1118 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1119 /* DATA INPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1120 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1121 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1122 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1123 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1124 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1125 /* DATA OUTPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1126 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1127 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1128 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1129 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1130 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1131 /* FAULT ADDRESS */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1132 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1133 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1134 /* SPECIAL STATUS WORD */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1135 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1136 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1137 /* 1000, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1138 m68ki_push_16(m68k, 0x8000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1139 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1140 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1141 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1142 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1143 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1144 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1145 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1146 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1147 /* Format A stack frame (short bus fault). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1148 * This is used only by 68020 for bus fault and address error |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1149 * if the error happens at an instruction boundary. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1150 * PC stacked is address of next instruction. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1151 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1152 static inline void m68ki_stack_frame_1010(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1153 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1154 //int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1155 //int orig_fc = m68k->mmu_tmp_buserror_fc; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1156 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1157 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1158 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1159 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1160 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1161 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1162 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1163 /* DATA OUTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1164 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1165 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1166 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1167 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1168 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1169 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1170 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1171 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1172 /* DATA CYCLE FAULT ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1173 m68ki_push_32(m68k, fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1174 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1175 /* INSTRUCTION PIPE STAGE B */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1176 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1177 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1178 /* INSTRUCTION PIPE STAGE C */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1179 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1180 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1181 /* SPECIAL STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1182 // set bit for: Rerun Faulted bus Cycle, or run pending prefetch |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1183 // set FC |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1184 m68ki_push_16(m68k, 0x0100 /*| orig_fc | orig_rw<<6*/); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1185 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1186 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1187 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1188 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1189 /* 1010, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1190 m68ki_push_16(m68k, 0xa000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1191 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1192 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1193 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1194 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1195 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1196 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1197 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1198 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1199 /* Format B stack frame (long bus fault). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1200 * This is used only by 68020 for bus fault and address error |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1201 * if the error happens during instruction execution. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1202 * PC stacked is address of instruction in progress. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1203 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1204 static inline void m68ki_stack_frame_1011(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1205 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1206 /*int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1207 int orig_fc = m68k->mmu_tmp_buserror_fc;*/ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1208 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1209 /* INTERNAL REGISTERS (18 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1210 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1211 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1212 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1213 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1214 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1215 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1216 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1217 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1218 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1219 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1220 /* VERSION# (4 bits), INTERNAL INFORMATION */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1221 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1222 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1223 /* INTERNAL REGISTERS (3 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1224 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1225 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1226 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1227 /* DATA INTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1228 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1229 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1230 /* INTERNAL REGISTERS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1231 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1232 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1233 /* STAGE B ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1234 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1235 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1236 /* INTERNAL REGISTER (4 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1237 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1238 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1239 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1240 /* DATA OUTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1241 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1242 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1243 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1244 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1245 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1246 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1247 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1248 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1249 /* DATA CYCLE FAULT ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1250 m68ki_push_32(m68k, fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1251 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1252 /* INSTRUCTION PIPE STAGE B */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1253 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1254 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1255 /* INSTRUCTION PIPE STAGE C */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1256 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1257 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1258 /* SPECIAL STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1259 m68ki_push_16(m68k, 0x0100/* | orig_fc | orig_rw<<6*/); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1260 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1261 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1262 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1263 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1264 /* 1011, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1265 m68ki_push_16(m68k, 0xb000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1266 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1267 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1268 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1269 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1270 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1271 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1272 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1273 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1274 /* Type 7 stack frame (access fault). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1275 * This is used by the 68040 for bus fault and mmu trap |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1276 * 30 words |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1277 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1278 static inline void m68ki_stack_frame_0111(m68000_base_device *m68k, uint32_t sr, uint32_t vector, uint32_t pc, uint32_t fault_address, uint8_t in_mmu) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1279 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1280 /*int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1281 int orig_fc = m68k->mmu_tmp_buserror_fc;*/ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1282 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1283 /* INTERNAL REGISTERS (18 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1284 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1285 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1286 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1287 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1288 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1289 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1290 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1291 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1292 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1293 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1294 /* FAULT ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1295 m68ki_push_32(m68k, fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1296 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1297 /* INTERNAL REGISTERS (3 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1298 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1299 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1300 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1301 /* SPECIAL STATUS REGISTER (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1302 m68ki_push_16(m68k, 0/*(in_mmu ? 0x400 : 0) | orig_fc | (orig_rw<<8)*/); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1303 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1304 /* EFFECTIVE ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1305 m68ki_push_32(m68k, fault_address); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1306 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1307 /* 0111, VECTOR OFFSET (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1308 m68ki_push_16(m68k, 0x7000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1309 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1310 /* PROGRAM COUNTER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1311 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1312 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1313 /* STATUS REGISTER (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1314 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1315 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1316 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1317 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1318 /* Used for Group 2 exceptions. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1319 * These stack a type 2 frame on the 020. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1320 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1321 static inline void m68ki_exception_trap(m68000_base_device *m68k, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1322 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1323 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1324 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1325 if(CPU_TYPE_IS_010_LESS(m68k->cpu_type)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1326 m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1327 else |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1328 m68ki_stack_frame_0010(m68k, sr, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1329 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1330 m68ki_jump_vector(m68k, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1331 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1332 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1333 m68k->c.current_cycle += m68k->cyc_exception[vector]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1334 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1335 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1336 /* Trap#n stacks a 0 frame but behaves like group2 otherwise */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1337 static inline void m68ki_exception_trapN(m68000_base_device *m68k, uint32_t vector) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1338 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1339 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1340 m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1341 m68ki_jump_vector(m68k, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1342 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1343 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1344 m68k->c.current_cycle += m68k->cyc_exception[vector]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1345 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1346 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1347 /* Exception for trace mode */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1348 static inline void m68ki_exception_trace(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1349 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1350 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1351 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1352 if(CPU_TYPE_IS_010_LESS(m68k->cpu_type)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1353 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1354 if(CPU_TYPE_IS_000(m68k->cpu_type)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1355 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1356 m68k->instr_mode = INSTRUCTION_NO; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1357 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1358 m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, EXCEPTION_TRACE); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1359 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1360 else |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1361 m68ki_stack_frame_0010(m68k, sr, EXCEPTION_TRACE); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1362 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1363 m68ki_jump_vector(m68k, EXCEPTION_TRACE); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1364 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1365 /* Trace nullifies a STOP instruction */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1366 m68k->stopped &= ~STOP_LEVEL_STOP; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1367 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1368 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1369 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_TRACE]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1370 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1371 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1372 /* Exception for privilege violation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1373 static inline void m68ki_exception_privilege_violation(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1374 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1375 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1376 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1377 if(CPU_TYPE_IS_000(m68k->cpu_type)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1378 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1379 m68k->instr_mode = INSTRUCTION_NO; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1380 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1381 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1382 m68ki_stack_frame_0000(m68k, REG_PPC(m68k), sr, EXCEPTION_PRIVILEGE_VIOLATION); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1383 m68ki_jump_vector(m68k, EXCEPTION_PRIVILEGE_VIOLATION); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1384 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1385 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1386 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_PRIVILEGE_VIOLATION] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1387 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1388 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1389 /* Exception for A-Line instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1390 static inline void m68ki_exception_1010(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1391 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1392 uint32_t sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1393 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1394 sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1395 m68ki_stack_frame_0000(m68k, REG_PPC(m68k), sr, EXCEPTION_1010); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1396 m68ki_jump_vector(m68k, EXCEPTION_1010); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1397 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1398 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1399 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_1010] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1400 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1401 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1402 /* Exception for F-Line instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1403 static inline void m68ki_exception_1111(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1404 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1405 uint32_t sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1406 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1407 sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1408 m68ki_stack_frame_0000(m68k, REG_PPC(m68k), sr, EXCEPTION_1111); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1409 m68ki_jump_vector(m68k, EXCEPTION_1111); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1410 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1411 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1412 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_1111] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1413 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1414 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1415 /* Exception for illegal instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1416 static inline void m68ki_exception_illegal(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1417 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1418 uint32_t sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1419 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1420 sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1421 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1422 if(CPU_TYPE_IS_000(m68k->cpu_type)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1423 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1424 m68k->instr_mode = INSTRUCTION_NO; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1425 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1426 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1427 m68ki_stack_frame_0000(m68k, REG_PPC(m68k), sr, EXCEPTION_ILLEGAL_INSTRUCTION); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1428 m68ki_jump_vector(m68k, EXCEPTION_ILLEGAL_INSTRUCTION); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1429 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1430 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1431 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_ILLEGAL_INSTRUCTION] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1432 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1433 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1434 /* Exception for format errror in RTE */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1435 static inline void m68ki_exception_format_error(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1436 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1437 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1438 m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, EXCEPTION_FORMAT_ERROR); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1439 m68ki_jump_vector(m68k, EXCEPTION_FORMAT_ERROR); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1440 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1441 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1442 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_FORMAT_ERROR] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1443 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1444 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1445 /* Exception for address error */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1446 static inline void m68ki_exception_address_error(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1447 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1448 uint32_t sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1449 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1450 /* If we were processing a bus error, address error, or reset, |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1451 * this is a catastrophic failure. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1452 * Halt the CPU |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1453 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1454 if(m68k->run_mode == RUN_MODE_BERR_AERR_RESET) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1455 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1456 //m68k->/*memory.*/read8(0x00ffff01); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1457 m68k->stopped = STOP_LEVEL_HALT; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1458 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1459 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1460 m68k->run_mode = RUN_MODE_BERR_AERR_RESET; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1461 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1462 /* Note: This is implemented for 68000 only! */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1463 m68ki_stack_frame_buserr(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1464 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1465 m68ki_jump_vector(m68k, EXCEPTION_ADDRESS_ERROR); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1466 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1467 /* Use up some clock cycles and undo the instruction's cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1468 m68k->c.current_cycle += m68k->cyc_exception[EXCEPTION_ADDRESS_ERROR] - m68k->cyc_instruction[m68k->ir]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1469 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1470 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1471 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1472 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1473 /* ASG: Check for interrupts */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1474 static inline void m68ki_check_interrupts(m68000_base_device *m68k) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1475 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1476 /*if(m68k->nmi_pending) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1477 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1478 m68k->nmi_pending = false; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1479 m68k->m68ki_exception_interrupt(m68k, 7); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1480 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1481 else if(m68k->int_level > m68k->int_mask) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1482 m68k->m68ki_exception_interrupt(m68k, m68k->int_level>>8);*/ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1483 if (m68k->c.current_cycle >= m68k->c.int_cycle) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1484 m68ki_exception_interrupt(m68k, m68k->c.int_num); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1485 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1486 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1487 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1488 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1489 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1490 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1491 /* ============================== END OF FILE ============================= */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1492 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1493 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1494 #endif /* __M68KCPU_H__ */ |