Wed, 16 Apr 2014 02:20:43 -0600
fixed bus error handling for real this time (save registers before every instruction and push the saved registers if a bus error occurs, since the instruction may have changed registers before the bus error, and also stop the instruction immediately with longjmp so it won't change memory after the bus error)
This isn't actually what a real 68k does, but it is a good enough approximation. A real 68k will jump back into the middle of the faulted instruction and resume it from the memory access that faulted as opposed to restarting from the beginning like this CPU emulation does. It would be a lot harder to do that with the way this CPU library is designed. Newer versions of MESS basically do the same thing (they use a newer version of this library).
1 The history of Musashi for anyone who might be interested:
2 ---------------------------------------------------------
4 Musashi was born out of sheer boredom.
5 I needed something to code, and so having had fun with a few of the emulators
6 around, I decided to try my hand at CPU emulation.
7 I had owned an Amiga for many years and had done some assembly coding on it so
8 I figured it would be the ideal chip to cut my teeth on.
9 Had I known then how much work was involved in emulating a chip like this, I
10 may not have even started ;-)
14 12-May-1998: First outline
16 11-Jun-1998: Early disassembler
18 20-Nov-1998: First prototype v0.1
20 04-Dec-1998: Final prototype v0.4
22 20-Dec-1998: Beta release of Musashi v0.5 that could run Rastan Saga under MAME
23 (barely).
25 06-Jan-1999: Musashi 1.0 released
27 17-Mar-1999: Musashi 2.0 released
28 - Major code overhaul.
29 - Replaced monolithic codebase with a code generator program.
30 - Added correct m68000 timing.
31 - Moved timing into the opcode handlers.
33 25-Mar-1999: Musashi 2.1 released
34 - Added support for m68010.
35 - Many bugfixes.
37 13-May-1999: Musashi 2.2 released
38 - Added support for m68020.
39 - Lots of bugfixes.
41 05-Apr-2000: Musashi 3.0 released
42 - Major code overhaul.
43 - Rewrote code generator program and changed the format of
44 m68k_in.c.
45 - Added support for m68ec020.
46 - Removed timing from the opcode handlers.
47 - Added correct timing for m68000, m68010, and m68020.
48 Note: 68020 timing is the cache timing from the manual.
49 - Removed the m68k_peek_xxx() and m68k_poke_xxx() instructions and
50 replaced them with m68k_get_reg() and m68k_set_reg().
51 - Added support for function codes.
52 - Revamped m68kconf.h to be easier to configure and more powerful.
53 - Added option to separate immediate and normal reads.
54 - Added support for (undocumented) m68000 instruction prefetch.
55 - Rewrote indexed addressing mode handling.
56 - Rewrote interrupt handling.
57 - Fixed a masking bug for m68k_get_reg() when requesting the PC.
58 - Moved the instruction table sorting routine to m68kmake.c so
59 that it is invoked at compile time rather than at runtime.
60 - Rewrote the exception handling routines to support different
61 stack frames (needed for m68020 emulation).
62 - Rewrote faster status register and condition code flag handling
63 functions / macros.
64 - Fixed function code handling to fetch from program space when
65 using pc-relative addressing.
66 - Fixed initial program counter and stack pointer fetching on
67 reset (loads from program space now).
68 - A lot of code cleanup.
69 - LOTS of bugfixes (especially in the m68020 code).
71 28-May-2000: Musashi 3.1 released
72 - Fixed bug in m68k_get_reg() that retrieved the wrong value for
73 the status register.
74 - Fixed register bug in movec.
75 - Fixed cpu type comparison problem that caused indexed
76 addressing modes to be incorrectly interpreted when in m68ec020
77 mode.
78 - Added code to speed up busy waiting on some branch instructions.
79 - Fixed some bfxxx opcode bugs.
81 14-Aug-2000: Musashi 3.2 released
82 - Fixed RTE bug that killed the program counter when in m68020
83 mode.
84 - Minor fixes in negx and nbcd.
85 - renamed d68k.c to m68kdasm.c and merged d68k.h into m68k.h.
86 d68k_read_xxx() instructions have been renamed to
87 m68k_read_xxx_disassembler().
88 - Rewrote exception processing and fixed 68020 stack frame
89 problems.
90 - FINALLY fixed the mull and divl instructions.
91 - Added 64-bit safe code fixes.
92 - Added 64-bit optimizations (these will only be ANSI compliant
93 under c9x, and so to use them you must turn on M68K_USE_64_BIT
94 in m68kconf.h).
96 27-Jan-2001: Musashi 3.3 released
97 Note: This is the last release of Musashi before I separate the
98 68020 core.
99 - Fixed problem when displaying negative numbers in disassembler
100 - Fixed cpu type selector - was allowing 020 instructions to be
101 disassembled when in 000 mode.
102 - Fixed opcode jumptable generator (ambiguous operators in the
103 test for f-line ops)
104 - Fixed signed/unsigned problem in divl and mull opcodes (not
105 sure if this was causing an error but best to be sure)
106 - Cleaned up the naming scheme for the opcode handlers
108 02-Feb-2001: Musashi 3.3.1 released
109 Note: due to the pc-relative requirement for some new drivers
110 in MAME, I've released this small update.
111 - Added pc-relative read modes
112 - small optimizations to the exception handling that will help
113 when splitting the cores
114 - Updated the example (oops!)