Mercurial > repos > blastem
annotate musashi/m68kcpu.h @ 1509:36732f5c2281 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 31 Dec 2017 10:11:16 -0800 |
parents | 2e57910fd641 |
children | 13abdc98379e |
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; |
1508
2e57910fd641
More efficient memory access when using MAME interpreters
Michael Pavone <pavone@retrodev.com>
parents:
1507
diff
changeset
|
58 void *read_pointers[24*1024/64]; |
2e57910fd641
More efficient memory access when using MAME interpreters
Michael Pavone <pavone@retrodev.com>
parents:
1507
diff
changeset
|
59 void *write_pointers[24*1024/64]; |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 }; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 /* Special interrupt acknowledge values. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 * 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
|
64 * (specified later in this header). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 /* 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
|
68 * 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
|
69 * acknowledge cycle instead of DTACK. |
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 #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
|
72 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 /* 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
|
74 * 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
|
75 * 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
|
76 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 #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
|
78 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 #include <limits.h> |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 #if defined(__sun__) && defined(__svr4__) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 #undef REG_SP |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 #undef REG_PC |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 #undef REG_FP |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 #endif |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 |
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 /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 /* Check for > 32bit sizes */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 #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
|
93 #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
|
94 #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
|
95 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 |
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 /* ============================ GENERAL DEFINES =========================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 /* Exception Vectors handled by emulation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 #define EXCEPTION_RESET 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 #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
|
104 #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
|
105 #define EXCEPTION_ILLEGAL_INSTRUCTION 4 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 #define EXCEPTION_ZERO_DIVIDE 5 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 #define EXCEPTION_CHK 6 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 #define EXCEPTION_TRAPV 7 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 #define EXCEPTION_PRIVILEGE_VIOLATION 8 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 #define EXCEPTION_TRACE 9 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 #define EXCEPTION_1010 10 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 #define EXCEPTION_1111 11 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 #define EXCEPTION_FORMAT_ERROR 14 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 #define EXCEPTION_UNINITIALIZED_INTERRUPT 15 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 #define EXCEPTION_SPURIOUS_INTERRUPT 24 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 #define EXCEPTION_INTERRUPT_AUTOVECTOR 24 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 #define EXCEPTION_TRAP_BASE 32 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 /* 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
|
120 #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
|
121 #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
|
122 #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
|
123 #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
|
124 #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
|
125 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 /* 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
|
127 #define CPU_TYPE_000 (0x00000001) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 #define CPU_TYPE_008 (0x00000002) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 #define CPU_TYPE_010 (0x00000004) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 #define CPU_TYPE_EC020 (0x00000008) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 #define CPU_TYPE_020 (0x00000010) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 #define CPU_TYPE_EC030 (0x00000020) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 #define CPU_TYPE_030 (0x00000040) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 #define CPU_TYPE_EC040 (0x00000080) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 #define CPU_TYPE_LC040 (0x00000100) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 #define CPU_TYPE_040 (0x00000200) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 #define CPU_TYPE_SCC070 (0x00000400) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 #define CPU_TYPE_FSCPU32 (0x00000800) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 #define CPU_TYPE_COLDFIRE (0x00001000) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 /* 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
|
142 #define STOP_LEVEL_STOP 1 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 #define STOP_LEVEL_HALT 2 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 /* 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
|
146 #define INSTRUCTION_YES 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 #define INSTRUCTION_NO 0x08 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 #define MODE_READ 0x10 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 #define MODE_WRITE 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 #define RUN_MODE_NORMAL 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 #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
|
153 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 #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
|
157 #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
|
158 #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
|
159 #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
|
160 #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
|
161 |
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 /* ================================ MACROS ================================ */ |
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 |
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 /* ---------------------------- General Macros ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 /* Bit Isolation Macros */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 #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
|
171 #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
|
172 #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
|
173 #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
|
174 #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
|
175 #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
|
176 #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
|
177 #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
|
178 #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
|
179 #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
|
180 #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
|
181 #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
|
182 #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
|
183 #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
|
184 #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
|
185 #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
|
186 #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
|
187 #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
|
188 #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
|
189 #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
|
190 #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
|
191 #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
|
192 #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
|
193 #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
|
194 #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
|
195 #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
|
196 #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
|
197 #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
|
198 #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
|
199 #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
|
200 #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
|
201 #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
|
202 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 /* 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
|
204 #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
|
205 #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
|
206 #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
|
207 #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
|
208 #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
|
209 #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
|
210 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 /* Isolate nibbles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 #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
|
213 #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
|
214 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 /* 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
|
216 #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
|
217 #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
|
218 #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
|
219 #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
|
220 #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
|
221 #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
|
222 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 /* 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
|
224 #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
|
225 #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
|
226 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 /* Shift & Rotate Macros. */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 #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
|
229 #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
|
230 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 /* 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
|
232 * by >= data size are undefined. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 #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
|
235 #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
|
236 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 #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
|
238 #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
|
239 #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
|
240 #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
|
241 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 #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
|
243 #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
|
244 #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
|
245 #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
|
246 #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
|
247 #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
|
248 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 #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
|
250 #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
|
251 #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
|
252 #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
|
253 #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
|
254 #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
|
255 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 |
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 /* ------------------------------ CPU Access ------------------------------ */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 /* Access the CPU registers */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 #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
|
262 #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
|
263 #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
|
264 #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
|
265 #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
|
266 #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
|
267 #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
|
268 #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
|
269 #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
|
270 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 |
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 /* ----------------------------- Configuration ---------------------------- */ |
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 /* 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
|
276 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 /* 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
|
278 #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
|
279 |
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
|
280 #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
|
281 #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
|
282 |
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
|
283 #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
|
284 #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
|
285 |
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
|
286 #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
|
287 #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
|
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_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
|
290 |
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
|
291 #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
|
292 #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
|
293 |
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
|
294 #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
|
295 #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
|
296 #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
|
297 |
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
|
298 #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
|
299 |
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 /* -------------------------- EA / Operand Access ------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 /* |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 * 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
|
305 * .... XXX. .... .YYY |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 * 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
|
307 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 /* Data Register Isolation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 #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
|
310 #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
|
311 /* Address Register Isolation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 #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
|
313 #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
|
314 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 /* Effective Address Calculations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 #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
|
318 #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
|
319 #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
|
320 #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
|
321 #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
|
322 #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
|
323 #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
|
324 #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
|
325 #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
|
326 #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
|
327 #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
|
328 #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
|
329 #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
|
330 #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
|
331 #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
|
332 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 #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
|
334 #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
|
335 #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
|
336 #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
|
337 #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
|
338 #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
|
339 #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
|
340 #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
|
341 #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
|
342 #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
|
343 #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
|
344 #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
|
345 #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
|
346 #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
|
347 #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
|
348 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 #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
|
350 #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
|
351 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 #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
|
353 #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
|
354 #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
|
355 #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
|
356 #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
|
357 #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
|
358 #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
|
359 #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
|
360 #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
|
361 #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
|
362 #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
|
363 #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
|
364 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 #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
|
367 #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
|
368 #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
|
369 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 |
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 /* --------------------------- Status Register ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 /* Flag Calculation Macros */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 #define CFLAG_8(A) (A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 #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
|
377 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 #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
|
379 #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
|
380 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 #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
|
382 #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
|
383 #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
|
384 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 #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
|
386 #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
|
387 #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
|
388 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 #define NFLAG_8(A) (A) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 #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
|
391 #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
|
392 #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
|
393 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 #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
|
395 #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
|
396 #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
|
397 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 /* Flag values */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
400 #define NFLAG_SET 0x80 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
401 #define NFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
402 #define CFLAG_SET 0x100 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 #define CFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 #define XFLAG_SET 0x100 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 #define XFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
406 #define VFLAG_SET 0x80 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 #define VFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
408 #define ZFLAG_SET 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 #define ZFLAG_CLEAR 0xffffffff |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
410 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
411 #define SFLAG_SET 4 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 #define SFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 #define MFLAG_SET 2 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 #define MFLAG_CLEAR 0 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 /* 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
|
417 #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
|
418 #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
|
419 #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
|
420 #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
|
421 #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
|
422 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 /* Conditions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
425 #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
|
426 #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
|
427 #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
|
428 #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
|
429 #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
|
430 #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
|
431 #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
|
432 #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
|
433 #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
|
434 #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
|
435 #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
|
436 #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
|
437 #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
|
438 #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
|
439 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 /* Reversed conditions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 #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
|
442 #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
|
443 #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
|
444 #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
|
445 #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
|
446 #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
|
447 #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
|
448 #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
|
449 #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
|
450 #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
|
451 #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
|
452 #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
|
453 #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
|
454 #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
|
455 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 /* 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
|
457 #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
|
458 #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
|
459 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 /* Get the condition code register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 #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
|
463 (COND_MI(M) >> 4) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 (COND_EQ(M) << 2) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 (COND_VS(M) >> 6) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 (COND_CS(M) >> 8)) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
467 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 /* 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
|
469 #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
|
470 /*(M)->t0_flag |*/ \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 ((M)->s_flag << 11) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 ((M)->m_flag << 11) | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 (M)->int_mask | \ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 m68ki_get_ccr(M)) |
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 |
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 / Write ----------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 /* 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
|
481 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
|
482 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
|
483 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
|
484 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 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
|
486 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 /*#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
|
488 #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
|
489 #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
|
490 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
491 /* 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
|
492 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
|
493 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
|
494 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
|
495 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 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
|
497 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
|
498 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 /* |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 #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
|
501 #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
|
502 #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
|
503 #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
|
504 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 /* 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
|
506 #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
|
507 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 |
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 /* =============================== PROTOTYPES ============================= */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
511 /* ======================================================================== */ |
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 union fp_reg |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
514 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
515 uint64_t i; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
516 double f; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
517 }; |
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 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
|
520 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 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
|
526 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
|
527 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 /* 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
|
529 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
|
530 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
|
531 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
532 /* 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
|
533 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
|
534 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
|
535 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
|
536 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
537 /* 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
|
538 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
|
539 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
|
540 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
|
541 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
542 /* Operand fetching */ |
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_8(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_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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 |
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_8(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_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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
575 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
|
576 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
|
577 |
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_8(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_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
|
580 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
591 /* Stack operations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
592 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
|
593 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
|
594 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
|
595 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
|
596 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
597 /* Program flow operations */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 /* Status register operations. */ |
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_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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
611 /* Exception processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
612 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
|
613 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
614 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
|
615 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
|
616 |
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_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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 |
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_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
|
626 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
|
627 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
|
628 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
|
629 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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
635 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
|
636 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
637 /* quick disassembly (used for logging) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
638 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
|
639 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
644 #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
|
645 #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
|
646 /* 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
|
647 #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
|
648 /* 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
|
649 #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
|
650 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
651 |
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 /* =========================== UTILITY FUNCTIONS ========================== */ |
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 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
656 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
657 /* 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
|
658 * predecrement destination mode is executed. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
659 * 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
|
660 * low word to [address]. |
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 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
|
663 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
664 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
|
665 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
|
666 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
667 |
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 /* ---------------------------- Read Immediate ---------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
670 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
671 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
672 /* 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
|
673 * 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
|
674 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
675 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
|
676 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
677 uint32_t result; |
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 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
|
680 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
681 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
|
682 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
|
683 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
684 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
|
685 REG_PC(m68k) += 2; |
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 return result; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
688 } |
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 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
|
691 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
692 uint32_t temp_val; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
693 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
|
694 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
695 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
|
696 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
|
697 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
698 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
|
699 REG_PC(m68k) += 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
700 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
|
701 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
|
702 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
703 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
|
704 REG_PC(m68k) += 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
705 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
|
706 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
|
707 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
708 return temp_val; |
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 |
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 /* --------------------- Effective Address Calculation -------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
713 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
714 /* 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
|
715 * 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
|
716 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 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
|
718 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
719 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
|
720 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
|
721 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
722 |
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 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
|
725 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
726 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
|
727 } |
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 /* 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
|
730 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
731 * Base instruction format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 * 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
|
733 * 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
|
734 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
735 * 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
|
736 * 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
|
737 * 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
|
738 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 * Brief extension format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
740 * 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
|
741 * 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
|
742 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
743 * Full extension format: |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
744 * 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
|
745 * 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
|
746 * 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
|
747 * 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
|
748 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
749 * 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
|
750 * 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
|
751 * 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
|
752 * 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
|
753 * 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
|
754 * 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
|
755 * |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
756 * IS I/IS Operation |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
757 * 0 000 No Memory Indirect |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
758 * 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
|
759 * 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
|
760 * 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
|
761 * 0 100 reserved |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
762 * 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
|
763 * 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
|
764 * 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
|
765 * 1 000 no memory indirect |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
766 * 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
|
767 * 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
|
768 * 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
|
769 * 1 100-111 reserved |
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 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
|
772 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
773 /* An = base register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
774 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
|
775 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
|
776 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
|
777 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
|
778 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
779 /* Calculate index */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 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
|
781 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
|
782 Xn = MAKE_INT_16(Xn); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
783 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
784 /* 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
|
785 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
|
786 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
787 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
789 /* Fetch operands */ |
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_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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 |
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_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
|
807 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
|
808 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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
822 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
|
823 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
|
824 |
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_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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
838 |
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 /* ---------------------------- Stack Functions --------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
841 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
842 /* 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
|
843 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
|
844 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
845 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
|
846 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
|
847 } |
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 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
|
850 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
851 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
|
852 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
|
853 } |
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 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
|
856 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
857 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
|
858 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
|
859 } |
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 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
|
862 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
863 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
|
864 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
|
865 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
866 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
867 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
868 /* 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
|
869 * 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
|
870 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
871 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
|
872 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
873 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
|
874 } |
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 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
|
877 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
878 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
|
879 } |
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 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
|
882 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
883 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
|
884 } |
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 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
|
887 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
888 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
|
889 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
890 |
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 /* ----------------------------- Program Flow ----------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
893 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
894 /* 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
|
895 * 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
|
896 * in m68kconf.h. |
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 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
|
899 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
900 REG_PC(m68k) = new_pc; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
901 } |
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 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
|
904 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
905 REG_PC(m68k) = (vector<<2); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
906 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
|
907 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
908 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
909 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
910 /* 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
|
911 * 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
|
912 * 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
|
913 * bit branches. |
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 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
|
916 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
917 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
|
918 } |
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 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
|
921 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
922 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
|
923 } |
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 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
|
926 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
927 REG_PC(m68k) += offset; |
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 |
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 /* ---------------------------- Status Register --------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
933 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
934 /* 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
|
935 * 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
|
936 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
937 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
|
938 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
939 /* Backup the old stack pointer */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
940 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
|
941 //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
|
942 /* Set the S flag */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
943 if (value != m68k->s_flag) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
944 m68k->s_flag = value; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
945 /* Set the new stack pointer */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
946 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
|
947 REG_USP(m68k) = old; |
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 //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
|
950 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
951 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
952 /* 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
|
953 * 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
|
954 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
955 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
|
956 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
957 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
|
958 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
959 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
960 /* 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
|
961 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
|
962 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
963 /* 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
|
964 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
|
965 //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
|
966 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
967 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
968 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
969 /* Set the condition code register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
970 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
|
971 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
978 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
979 /* 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
|
980 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
|
981 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
982 /* Mask out the "unimplemented" bits */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
983 value &= m68k->sr_mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
984 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
985 /* 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
|
986 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
|
987 //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
|
988 m68k->int_mask = value & 0x0700; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
989 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
|
990 m68ki_set_ccr(m68k, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
991 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
|
992 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
993 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
994 /* 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
|
995 * change the stack pointer |
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 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
|
998 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
999 /* Mask out the "unimplemented" bits */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1000 value &= m68k->sr_mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1001 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1002 /* 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
|
1003 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
|
1004 //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
|
1005 m68k->int_mask = value & 0x0700; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1006 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
|
1007 m68ki_set_ccr(m68k, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1008 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
|
1009 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1010 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1011 /* 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
|
1012 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
|
1013 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1014 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
|
1015 m68ki_check_interrupts(m68k); |
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 |
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 /* ------------------------- Exception Processing ------------------------- */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1020 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1021 /* Initiate exception processing */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1022 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
|
1023 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1024 /* Save the old status register */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1025 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
|
1026 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1027 /* 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
|
1028 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
|
1029 m68ki_clear_trace(m68k); |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1030 /* Enter supervisor mode */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1031 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
|
1032 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1033 return sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1034 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1035 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1036 /* 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
|
1037 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
|
1038 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1039 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1040 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1041 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1042 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1043 /* Format 0 stack frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1044 * 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
|
1045 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1046 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
|
1047 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1048 /* 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
|
1049 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
|
1050 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1051 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
|
1052 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1053 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1054 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
|
1055 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1056 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1057 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1058 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1059 /* Format 1 stack frame (68020). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1060 * 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
|
1061 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1062 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
|
1063 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1064 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
|
1065 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1066 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1067 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1068 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1069 /* Format 2 stack frame. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1070 * 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
|
1071 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1072 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
|
1073 { |
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_PPC(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, 0x2000 | (vector<<2)); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1076 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
|
1077 m68ki_push_16(m68k, sr); |
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 |
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 /* 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
|
1082 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1083 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
|
1084 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1085 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
|
1086 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1087 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
|
1088 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
|
1089 /* 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
|
1090 * 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
|
1091 * 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
|
1092 * FC 3-bit function code |
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 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
|
1095 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1096 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1097 /* Format 8 stack frame (68010). |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1098 * 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
|
1099 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1100 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
|
1101 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1102 /* VERSION |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1103 * NUMBER |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1104 * INTERNAL INFORMATION, 16 WORDS |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1105 */ |
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 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1113 m68ki_fake_push_32(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1114 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1115 /* INSTRUCTION INPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1116 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1117 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1118 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1119 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1120 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1121 /* DATA INPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1122 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1123 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1124 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1125 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1126 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1127 /* DATA OUTPUT BUFFER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1128 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1129 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1130 /* UNUSED, RESERVED (not written) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1131 m68ki_fake_push_16(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1132 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1133 /* FAULT ADDRESS */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1134 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1135 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1136 /* SPECIAL STATUS WORD */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1137 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1138 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1139 /* 1000, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1140 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
|
1141 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1142 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1143 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1144 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1145 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1146 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1147 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1148 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1149 /* 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
|
1150 * 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
|
1151 * 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
|
1152 * 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
|
1153 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1154 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
|
1155 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1156 //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
|
1157 //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
|
1158 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1159 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1160 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1161 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1162 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1163 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1164 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1165 /* DATA OUTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1166 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1167 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1168 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1169 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1170 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1171 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1172 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1173 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1174 /* 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
|
1175 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
|
1176 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1177 /* INSTRUCTION PIPE STAGE B */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1178 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1179 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1180 /* INSTRUCTION PIPE STAGE C */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1181 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1182 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1183 /* SPECIAL STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1184 // 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
|
1185 // set FC |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1186 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
|
1187 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1188 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1189 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1190 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1191 /* 1010, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1192 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
|
1193 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1194 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1195 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1196 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1197 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1198 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1199 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1200 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1201 /* 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
|
1202 * 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
|
1203 * 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
|
1204 * 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
|
1205 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1206 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
|
1207 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1208 /*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
|
1209 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
|
1210 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1211 /* INTERNAL REGISTERS (18 words) */ |
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 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1220 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1221 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1222 /* VERSION# (4 bits), INTERNAL INFORMATION */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1223 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1224 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1225 /* INTERNAL REGISTERS (3 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1226 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1227 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1228 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1229 /* DATA INTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1230 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1231 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1232 /* INTERNAL REGISTERS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1233 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1234 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1235 /* STAGE B ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1236 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1237 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1238 /* INTERNAL REGISTER (4 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1239 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1240 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1241 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1242 /* DATA OUTPUT BUFFER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1243 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1244 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1245 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1246 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1247 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1248 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1249 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1250 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1251 /* 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
|
1252 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
|
1253 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1254 /* INSTRUCTION PIPE STAGE B */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1255 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1256 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1257 /* INSTRUCTION PIPE STAGE C */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1258 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1259 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1260 /* SPECIAL STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1261 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
|
1262 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1263 /* INTERNAL REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1264 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1265 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1266 /* 1011, VECTOR OFFSET */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1267 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
|
1268 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1269 /* PROGRAM COUNTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1270 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1271 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1272 /* STATUS REGISTER */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1273 m68ki_push_16(m68k, sr); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1274 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1275 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1276 /* 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
|
1277 * 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
|
1278 * 30 words |
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 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
|
1281 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1282 /*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
|
1283 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
|
1284 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1285 /* INTERNAL REGISTERS (18 words) */ |
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 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1294 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1295 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1296 /* FAULT ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1297 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
|
1298 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1299 /* INTERNAL REGISTERS (3 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1300 m68ki_push_32(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1301 m68ki_push_16(m68k, 0); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1302 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1303 /* SPECIAL STATUS REGISTER (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1304 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
|
1305 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1306 /* EFFECTIVE ADDRESS (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1307 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
|
1308 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1309 /* 0111, VECTOR OFFSET (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1310 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
|
1311 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1312 /* PROGRAM COUNTER (2 words) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1313 m68ki_push_32(m68k, pc); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1314 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1315 /* STATUS REGISTER (1 word) */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1316 m68ki_push_16(m68k, sr); |
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 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1319 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1320 /* Used for Group 2 exceptions. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1321 * 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
|
1322 */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1323 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
|
1324 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1325 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
|
1326 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1327 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
|
1328 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
|
1329 else |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1330 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
|
1331 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1332 m68ki_jump_vector(m68k, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1333 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1334 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1335 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
|
1336 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1337 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1338 /* 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
|
1339 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
|
1340 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1341 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
|
1342 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
|
1343 m68ki_jump_vector(m68k, vector); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1344 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1345 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1346 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
|
1347 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1348 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1349 /* Exception for trace mode */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1350 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
|
1351 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1352 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
|
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_010_LESS(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 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
|
1357 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1358 m68k->instr_mode = INSTRUCTION_NO; |
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 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
|
1361 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1362 else |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1363 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
|
1364 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1365 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
|
1366 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1367 /* Trace nullifies a STOP instruction */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1368 m68k->stopped &= ~STOP_LEVEL_STOP; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1369 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1370 /* Use up some clock cycles */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1371 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
|
1372 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1373 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1374 /* Exception for privilege violation */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1375 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
|
1376 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1377 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
|
1378 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1379 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
|
1380 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1381 m68k->instr_mode = INSTRUCTION_NO; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1382 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1383 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1384 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
|
1385 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
|
1386 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1387 /* 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
|
1388 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
|
1389 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1390 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1391 /* Exception for A-Line instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1392 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
|
1393 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1394 uint32_t sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1395 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1396 sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1397 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
|
1398 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
|
1399 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1400 /* 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
|
1401 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
|
1402 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1403 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1404 /* Exception for F-Line instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1405 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
|
1406 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1407 uint32_t sr; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1408 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1409 sr = m68ki_init_exception(m68k); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1410 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
|
1411 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
|
1412 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1413 /* 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
|
1414 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
|
1415 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1416 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1417 /* Exception for illegal instructions */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1418 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
|
1419 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1420 uint32_t sr; |
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 sr = m68ki_init_exception(m68k); |
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 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
|
1425 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1426 m68k->instr_mode = INSTRUCTION_NO; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1427 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1428 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1429 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
|
1430 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
|
1431 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1432 /* 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
|
1433 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
|
1434 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1435 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1436 /* 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
|
1437 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
|
1438 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1439 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
|
1440 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
|
1441 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
|
1442 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1443 /* 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
|
1444 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
|
1445 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1446 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1447 /* Exception for address error */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1448 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
|
1449 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1450 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
|
1451 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1452 /* 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
|
1453 * this is a catastrophic failure. |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1454 * Halt the CPU |
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 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
|
1457 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1458 //m68k->/*memory.*/read8(0x00ffff01); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1459 m68k->stopped = STOP_LEVEL_HALT; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1460 return; |
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 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
|
1463 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1464 /* 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
|
1465 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
|
1466 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1467 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
|
1468 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1469 /* 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
|
1470 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
|
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 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1474 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1475 /* ASG: Check for interrupts */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1476 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
|
1477 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1478 /*if(m68k->nmi_pending) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1479 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1480 m68k->nmi_pending = false; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1481 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
|
1482 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1483 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
|
1484 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
|
1485 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
|
1486 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
|
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 |
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 /* ============================== END OF FILE ============================= */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1494 /* ======================================================================== */ |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1495 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1496 #endif /* __M68KCPU_H__ */ |