Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
09146 Crash/Freeze Minor Always Mar 30, 2025, 10:59 Mar 30, 2025, 13:47
Tester Robbbert View Status Public Platform MAME (Self-compiled)
Assigned To Resolution Open OS Windows 10/11 (64-bit)
Status [?] Confirmed Driver
Version 0.275 Fixed in Version Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 09146: pokemini: If the divisor to the DIV instruction is zero, CPU should raise an exception
Description The instruction DIV HL/A (CE D9) will crash MAME if A is zero.

According to the information at https://www.pokemon-mini.net/documentation/minx-cpu/ , the CPU should hard-lock instead. That doesn't mean that MAME should stop responding, just that the CPU should no longer advance through the program.

~~~~~~~
MAME crash was fixed, but no divide by 0 exception handling
Steps To Reproduce The program that causes this issue is attached.

C:\MAME>mame pokemini -cart e:\data\nintendo\pokemini\ok\3dcubetest.min
Additional Information -----------------------------------------------------
Exception at EIP=00007ff786dd6061 (minx_cpu_device::execute_one_ce()+0x4ab1): INTEGER DIVIDE BY ZERO
-----------------------------------------------------
RAX=0000000000000910 RBX=000002c2be442f90 RCX=0000000000000910 RDX=0000000000000000
RSI=00000000000000d9 RDI=0000000000000000 RBP=00007ff792a25ce0 RSP=000000dd613c98e0
 R8=0000000000000000 R9=0000000000000000 R10=0000000000000000 R11=0000003a35294400
R12=0de0b6b3a7640000 R13=00007ff792a25ce0 R14=0000000000000353 R15=000000dd613c9d90
-----------------------------------------------------
Stack crawl:
  000000dd613c9930: 00007ff786dd6061 (minx_cpu_device::execute_one_ce()+0x4ab1)
  000000dd613c9990: 00007ff786ddc57a (minx_cpu_device::execute_one()+0x117a)
  000000dd613c99d0: 00007ff786de194d (minx_cpu_device::execute_run()+0x003d)
  000000dd613c9a50: 00007ff78476433c (device_scheduler::timeslice()+0x04ac)
  000000dd613c9bd0: 00007ff784761225 (running_machine::run(bool)+0x01c5)
  000000dd613cf1f0: 00007ff78790142c (mame_machine_manager::execute()+0x024c)
  000000dd613cf5e0: 00007ff78b65fcda (cli_frontend::start_execution(mame_machine_manager*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)+0x03ea)
  000000dd613cf8f0: 00007ff78b66030a (cli_frontend::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)+0x007a)
  000000dd613cf950: 00007ff7878fc1d7 (emulator_info::start_frontend(emu_options&, osd_interface&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)+0x0027)
  000000dd613cfd20: 00007ff78d320271 (luaopen_lfs+0xc6bd91)
  000000dd613cfd70: 00007ff7809912ee (__tmainCRTStartup+0x016e)
  000000dd613cfda0: 00007ff780991406 (mainCRTStartup+0x0016)
  000000dd613cfdd0: 00007ffda2847374 (BaseThreadInitThunk+0x0014)
  000000dd613cfe50: 00007ffda2afcc91 (RtlUserThreadStart+0x0021)
Github Commit
Flags Noted in Source
Regression Version
Affected Sets / Systems pokemini
Attached Files
zip file icon 3Dcubetest.zip (4,099 bytes) Mar 30, 2025, 10:59 Uploaded by Robbbert
3D Cube Test
Relationships
There are no relationship linked to this issue.
Notes
3
User avatar
No.23169
hap
Developer
Mar 30, 2025, 12:36
edited on: Mar 30, 2025, 12:45
from TODO note:
- DIV (CE D9) division by zero handling - is supposed to raise a EX4 exception. A real Pokemini unit will freeze. MAME currently will crash.

I removed the crash here, still no exception handling but at least it doesn't crash MAME anymore.
https://github.com/mamedev/mame/commit/04edb1b5543d7b961f51b96bdb6a3ee3be91465b
User avatar
No.23170
Robbbert
Moderator
Mar 30, 2025, 13:05
edited on: Mar 30, 2025, 13:06
Ah, hadn't known about the todo. Thanks for fixing the crash.

I'll change this to confirmed and let it be until someone eventually can make it the same as the real unit. I guess it can become the same as a Z80 HALT instruction, but without an interrupt to escape it.
User avatar
No.23171
hap
Developer
Mar 30, 2025, 13:45
I didn't look into it further. I assume the Pokemon Mini BIOS exception handler does a soft-lock, and it's not likely that the CPU itself locks up.