lgblgblgb / xemu

Emulations (running on Linux/Unix/Windows/macOS, utilizing SDL2) of some - mainly - 8 bit machines, including the Commodore LCD, Commodore 65, and the MEGA65 as well.
https://github.com/lgblgblgb/xemu/wiki
GNU General Public License v2.0
201 stars 31 forks source link

MEGA65: Hardware division gets the remainder wrong #387

Open lydon42 opened 1 year ago

lydon42 commented 1 year ago

Describe the bug if you put 14 00 00 00 and 03 00 00 00 in MULTINA and MULTINB,. the result should be AB AA AA AA 06 00 00 00 in the 64 bit DIVOUT register. On xemu (next branch f16e0aede) it is AA in the first byte instead.

hwdiv-on-xemu-next

Used version of the project next branch f16e0aede

To Reproduce

  1. MONITOR
  2. MFFD3670 FFD367F
  3. put AB AA AA AA 06 00 00 00 after >0FFD3770 and press return
  4. go up to the MFFD.. press return,check result.

Expected behavior hwdiv-on-r3hw

stefandd commented 9 months ago

should be remainder (not reminder)

lgblgblgb commented 8 months ago

https://github.com/MEGA65/mega65-rom-public/issues/101 An interesting case: 5211/193 = 27 (without remainder, per math) but it's not the very precise case with mega65-core, which also results in different result in ROM then. https://github.com/MEGA65/mega65-core/issues/505 https://github.com/MEGA65/mega65-core/issues/506 Some insights.

Breaking news

And: https://github.com/MEGA65/mega65-core/issues/786

I feel, this is still in the flux, and I should wait what the final solution should be, what I have to follow then. It's also possible that the current Xemu implementation will be the one with MEGA65, so ...

PR in mega65-core to fix round-off errors: https://github.com/MEGA65/mega65-core/pull/812 This likely will change the result of the exact remainder values anyway even on mega65-core! >>has been merged into the development branch of mega65-core already, it seems<<