pnr Posted May 27, 2018 Share Posted May 27, 2018 For testing a CPU core, I'm looking for diagnostic routines that test the functionality of a 9900 CPU. Maybe this was developed for one of the emulators? Or were those debugged by just throwing a lot of programs at them and fixing bugs where they did not execute as expected? All suggestions welcome. Quote Link to comment Share on other sites More sharing options...
+mizapf Posted May 27, 2018 Share Posted May 27, 2018 For MAME I did not use a formal test method. As you suspected, I let it converge against the ideal behavior, with the hope that errors cannot hide too long until they show up somewhere. This bit me twice: In Microsurgeon, the game was over right after the start. It turned out that the Subtract instruction failed to set the Carry bit when subtracting 0, something I did not expect (subtract means to add the complement, and it actually adds the one's complement of 0 (=FFFF) and fixes the result by adding 1). In a TMS9995-based arcade game, the timing was completely wrong. This was because I implemented the decrementer to subtract 1 every clock pulse, but it is only every four clock pulses. In hindsight, I could have made good use of such a program. Quote Link to comment Share on other sites More sharing options...
pnr Posted May 28, 2018 Author Share Posted May 28, 2018 Thanks for pointing out those gotcha's! The subtraction thing is a clever implementation trick, I think I will try that in the core. The ALU already needs to support "A and not B" for instructions like COC and SZC, so must have complemented B available anyway. Doing subtract as "A + not B + 1", where the "+ 1" is done by setting 'carry in' to one, means that the ALU only needs to implement an adder and not a subtractor as well. The MDEX operating system ("CP/M for the Marinchip M9900") has a program "BRAINS" that does a memory and a CPU check. However, I only have the executable, not the source. I'm not sure how thorough it is, it may only check for some common failure cases (e.g. CRU drivers fried). Quote Link to comment Share on other sites More sharing options...
+mizapf Posted May 28, 2018 Share Posted May 28, 2018 Particularly, one can see that it is not safe to rely on the hope that a glitch will show up quickly. I only noticed it when trying one special game. Quote Link to comment Share on other sites More sharing options...
Tursi Posted May 30, 2018 Share Posted May 30, 2018 Classic99 ran for many years with such bugs hidden in the CPU core too... some patterns are just not commonly used. I did write a simple CPU test program - it's in the Classic99 archive. It tests a couple of points on each instruction but is not at all comprehensive. It still found a couple of issues in my early development and was verified against hardware. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.