Commit graph

161 commits

Author SHA1 Message Date
8dcac80091 Don't silently skip an opcode just because of an unexpected mask 2025-04-03 18:49:01 +02:00
43de90a9df WIP support emulator traps similar to basilisk 2025-03-30 20:28:34 -05:00
Matt Evans
b3144f12c1 TIDY: m68kcpu: fix warnings 2025-01-01 16:19:41 +00:00
Matt Evans
c8c2089edd TIDY: m68kfpu: fix warnings 2025-01-01 16:19:41 +00:00
Matt Evans
0b85a7a648 Move most frequently-used items to start of m68ki_cpu_core
This enables faster access on ISAs having small immediate offsets (e.g. armv6m).
2024-05-28 23:48:48 +01:00
Matt Evans
d4c4aa290d HACK: Add fast opcode read
m68ki_read_opcode_16 is both a different access path for instructions
(meaning we can decode addresses with certain assumptions), and also can be
implemented faster (always an aligned 16b read).
2024-05-28 23:48:48 +01:00
Matt Evans
91ecb76b7b Add M68K_FAST_FUNC, allowing project-specific attributes
Currently used only on m68k_execute(), this macro allows a project
to flag functions that are performance-critica.  For example, on
microcontroller builds certain functions might be decorated to
ensure the build locates them in faster types of memory.
2024-05-28 23:46:49 +01:00
Matt Evans
765c5af223 Add M68K_BUS_ERR_ENABLE config
Some projects don't use the m68k_pulse_bus_error() interface, so
disabling it will save some cycles in the inner loop.
2024-05-28 23:46:46 +01:00
Matt Evans
c2695c09d7 Add M68K_FIXED_CPU_TYPE config, for static CPU type selection
For some projects, runtime selection of CPU type isn't required,
and burns both time and space.  This config option allows a build-
time selection of CPU model.
2024-05-28 23:46:41 +01:00
Matt Evans
2ff6fd0683 Add M68K_DYNAMIC_INSTR_TABLES for runtime-generated decode/cycle tables
The static decode jump table is built via m68kmake, and with a project
config can be used by the main runloop.

Add M68K_CYCLE_COUNTING to enable per-instruction cycle counts
versus accumulating a dummy (constant) cost per instruction.

Move the cycle-counting to a macro -- for now, CYCLE_COUNTING is only
supported when using DYNAMIC_INSTR_TABLES (as no static table gen
is provided yet).

Static jumptable saves 256K of RAM, and avoiding cycle counting
saves 320K!
2024-05-15 23:16:46 +01:00
Matt Evans
fc885ffb03 m68kmake: Generate static jump table
An alternative to the runtime-generated decode jump table, this generates
one at build time.  The dynamic one uses more RAM, and the static one
makes the binary bigger.

This is qualified on a new M68K_DYNAMIC_INSTR_TABLES option.
2024-05-15 23:15:55 +01:00
Matt Evans
7fcef8fe6a Add new config option to compile disassembler
The disassembler is fairly large, so this allows builds to
save some space if it's not required.
2024-05-15 23:15:47 +01:00
Karl Stenerud
2158f70810
Merge pull request #105 from bebbo/p4
implement and fix some fpu instructions
2024-02-08 10:14:42 +01:00
Karl Stenerud
0902af7aab
Merge pull request #104 from bebbo/p3
add fdmoved to the disassembler
2024-02-08 10:12:30 +01:00
Karl Stenerud
dc4ac26cd9
Merge pull request #103 from bebbo/p2
reported cycle count is bogus
2024-02-08 10:12:06 +01:00
Karl Stenerud
5708b9211d
Merge pull request #102 from bebbo/master
fix cycles for shift and mul
2024-02-08 10:11:32 +01:00
bebbo
ffdd51b18a implement and fix some fpu instructions 2024-02-03 21:32:57 +01:00
bebbo
ca418a4d61 add to the disassembler 2024-02-03 21:29:24 +01:00
bebbo
369f2e57f1 reported cycle count is bogus 2024-02-03 21:24:26 +01:00
bebbo
7ec87cd98a fix cycles for shift and mul 2024-02-03 21:18:59 +01:00
Karl Stenerud
fc7a6fc602
Merge pull request #80 from bsdphk/master
Minor fixes to keep modern compilers happy
2021-08-16 08:16:03 +02:00
Poul-Henning Kamp
7bb99d700c Add missing prototypes 2021-08-15 07:01:59 +00:00
Poul-Henning Kamp
5f08834807 Make diagnostic functions take const char * arguments. 2021-08-15 07:01:12 +00:00
Poul-Henning Kamp
91878a8c8f Add void argument to make these proper prototypes 2021-08-15 06:58:45 +00:00
Poul-Henning Kamp
0d5b364b78 Update cpu-name table to match the enum in m68k.h 2021-08-15 06:42:39 +00:00
Poul-Henning Kamp
5a98127e53 Add a missing comma 2021-08-15 06:42:18 +00:00
Karl Stenerud
d0ab9ace32
Merge pull request #78 from agentbooth/master
fix for Freebee emulator
2021-07-29 06:19:06 +02:00
shadyjesse
df4d10b9cb allow bus error to occur when already exception handling a bus error (fixes page fault within a page fault in Freebee emulator) 2021-07-22 18:06:08 -04:00
Karl Stenerud
9494c3be62 Update example readme since it was getting horribly out of date 2021-06-24 09:10:32 +02:00
Karl Stenerud
2b85f48031 Add symlink to softfloat so that example app can compile 2021-06-24 08:47:05 +02:00
Karl Stenerud
66d00ece8a
Merge pull request #75 from lleoha/fix-compile-errors
Fix compile errors.
2020-06-14 10:40:13 +02:00
Mateusz Kramarczyk
40e8cea1a4 Fix compile errors. 2020-06-13 15:09:11 +02:00
Karl Stenerud
8d0d7bb3b5
Merge pull request #74 from jotd666/master
misc instructions fixes & additions
2020-06-10 08:30:19 +02:00
jotd
8541cd65d5 fscc instruction: added (disp,Ax) mode 2020-06-09 23:13:45 +02:00
jotd
8633295412 in m68k_in.c
- fixed all CHK2/CMP2 instructions to support signed bounds. Previously it only worked with unsigned. Also sped up a bit
  by changing | by || in Z evaluation formula
- cptrapcc opcodes are still unsupported, but if no exception occurs, at least PC is properly updated
- trapt/trapcc 16 & 32 instructions: PC is updated before exception is triggered (or if exception isn't triggered). This fixes the
  return address value (just in case code returns from trap with RTE) and also the stackframe (XDAda 68040 compiler
  read the data parameter to check exception type, wrong exception type is read if stackframe is incorrect)

in m68kfpu.c

- fatalerror message fprintf => vfprintf
- added address register + displacement mode (mode 5, READ_EA_FPE/WRITE_EA_FPE), also changed prototype to it can be called with this mode
  from FMOVEM loop
- added immediate mode (READ_EA_FPE)
- fpgen_rm_reg (FMOVE to register): added a lot of missing condition code update (SET_CONDITION_CODES(REG_FP[dst]))
- added FSDIVS and FSMULS (easy as it's the same case as FDIV and FMUL). Updated condition codes for FDIV
- fmove_fpcr: connected softfloat 4 rounding modes to this instruction, that didn't set rounding at all, when it's
  perfectly emulated in softfloat module (just added:  float_rounding_mode = (REG_FPCR >> 4) & 0x3;)
- fmovem: added address register+displacement mode (READ_EA_FPE/WRITE_EA_FPE interface had to be changed)
- added FScc instruction
- note: number of cycles for the added instructions isn't exact
2020-06-07 11:45:28 +02:00
jotd
3b8e84fd83 m68k_in.c:
- fixed all CHK2/CMP2 instructions to support signed bounds. Previously it only worked with unsigned. Also sped up a bit
  by changing | by || in Z evaluation formula
- cptrapcc opcodes are still unsupported, but if no exception occurs, at least PC is properly updated
- trapt/trapcc 16 & 32 instructions: PC is updated before exception is triggered (or if exception isn't triggered). This fixes the
  return address value (just in case code returns from trap with RTE) and also the stackframe (XDAda 68040 compiler
  read the data parameter to check exception type, wrong exception type is read if stackframe is incorrect)

m68kfpu.c:

- fatalerror message fprintf => vfprintf
- added address register + displacement mode (mode 5, READ_EA_FPE/WRITE_EA_FPE), also changed prototype to it can be called with this mode
  from FMOVEM loop
- added immediate mode (READ_EA_FPE)
- fpgen_rm_reg (FMOVE to register): added a lot of missing condition code update (SET_CONDITION_CODES(REG_FP[dst]))
- added FSDIVS and FSMULS (easy as it's the same case as FDIV and FMUL). Updated condition codes for FDIV
- fmove_fpcr: connected softfloat 4 rounding modes to this instruction, that didn't set rounding at all, when it's
  perfectly emulated in softfloat module (just added:  float_rounding_mode = (REG_FPCR >> 4) & 0x3;)
- fmovem: added address register+displacement mode (READ_EA_FPE/WRITE_EA_FPE interface had to be changed)
- added FScc instruction
- note: number of cycles for the added instructions isn't exact
2020-06-06 14:41:52 +02:00
Karl Stenerud
8784597791 Clean up GCC compiler warnings.
Fixes #39
2020-05-27 06:22:41 +02:00
Karl Stenerud
6f04ba062e
Merge pull request #53 from zelurker/master
big fpu update
2019-12-15 08:35:14 +01:00
R. Belmont
de395aa3de M68k: Add more conditionals and FGETEXP instruction [R. Belmont] 2019-12-14 15:11:55 +01:00
Emmanuel Anne
d1fd51f474 Makefile: add some m68kcpu.c dependancies 2019-12-14 15:07:13 +01:00
R. Belmont
3db368e052 m680x0 FPU updates: [R. Belmont]
- BCD packed decimal now supported, including k-factor
 - Improved FSAVE/FRESTORE including FPU reset when restoring a NULL frame
 - FREM instruction supported
 - Better disassembly of FPU instructions
2019-12-14 15:06:35 +01:00
R. Belmont
3ec8f605b4 680x0 FPU update: [R. Belmont]
- Implemented FMOVECR
 - Added load extended PC relative indexed support
 - Cleanup some duplicated code
2019-12-14 14:38:14 +01:00
R. Belmont
7a934a8506 680x0 FPU updates [R. Belmont]
- Rewritten to use SoftFloat instead of unportable native FP math
 - Support added for Motorola 96-bit extended floats
 - More addressing modes and conditions supported

The taitojc games function identically to the old implementation (I stepped
through the main matrix multiply in dendeg and the registers never diverged)
and speed on Core 2 Duo is a wash - sometimes softfloat's faster, sometimes
not, but the difference on -str 90 never exceeded 1%.
2019-12-14 13:14:18 +01:00
R. Belmont
4cbdf6bb2f 680x0: Improve disassembly for various FMOVE forms [R. Belmont] 2019-12-14 09:14:43 +01:00
R. Belmont
8e1710d0f7 Properly show 32-bit displacement for 020+ A reg relative [R. Belmont] 2019-12-14 09:11:14 +01:00
Karl Stenerud
710f795aaf
Merge pull request #52 from zelurker/master
the pmmu emulation
2019-12-13 20:00:27 +01:00
Emmanuel Anne
7efac187bd follow mame choice again
m68kmmu.h uses functions from m68kfpu.c which are static, so m68kfpu.c
can't be compiled alone anymore if we want to keep some basic
compatibility... I know, it's not super clean, but it's not my
choice...!
Also pmmu_translate_addr can't be inline anymore because of this (there
are quite a few functions from m68kcpu.h using it, and it can be
included only in m68kcpu.c !)
2019-12-13 13:40:42 +01:00
R. Belmont
530f644bd3 MC680x0 update
- Reworked PMMU/core interface so PMMU now sees all cop 0 instructions
 - Improved disassembly of PMMU instructions
 - Preliminary 68LC040 support
 - Fixed disassembly for EC/LC variants of '030/'040
2019-12-13 13:40:05 +01:00
Emmanuel Anne
3639c27e9c move the pmmu translation from ADDRESS_68K to the _fc functions
too dangerous in the ADDRESS_68K macro, this thing must be called only
once by address.
2019-12-13 11:41:40 +01:00
Karl Stenerud
556c574387
Merge pull request #51 from zelurker/master
2 fixes for the previous patches
2019-12-13 09:40:46 +01:00