who knows a full test code for 6502?
who knows a full test code for 6502?
i had written a emulator for 6502,but i can't know it is right,so who can give me a full test code to test every instruction for it?thank u very much.
If you can use (or convert) python, you might get some mileage out of the testsuite in Mike's py65 emulator. A typical test looks like this [I've cut a few lines]
At the end of this 2006 thread "stable, tested 6502 core" (also found here) MikeJ says
I maintain the cores on fpgaarcade. That trick is how I found most of the problems in the T80 core, and is the reason it is more accurate than the T65 core which I have never got around to doing the same thing
after a discussion that indicates there is no good verification suite to be found. (Emulators are usually tested by running game code.)
Code: Select all
def test_adc_bcd_off_absolute_carry_clear_in_accumulator_zeroes(self):
mpu.a = 0
self._write(mpu.memory, 0x0000, (0x6D, 0x00, 0xC0)) #=> $0000 ADC $C000
mpu.memory[0xC000] = 0x00
mpu.step()
self.assertEquals(0x0003, mpu.pc)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.CARRY)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
Quote:
Quote:
It might be a fun project to run two cores in lock step running the same program and see how far they get before they get a different result.
- Mike Naberezny
- Site Admin
- Posts: 294
- Joined: 30 Aug 2002
- Location: Northern California
- Contact:
BigEd wrote:
If you can use (or convert) python, you might get some mileage out of the testsuite in Mike's py65 emulator.
That's not to say that Py65 or its tests are perfect; it's still early and I am sure this is far from the case. However, I do feel that having a good test harness is important for reaching good compatibility and minimizing bugs or regressions.
I started working on Py65 mainly because I am interested in a replacement for Michal Kowalski's 6502 Macroassembler and Simulator. While I think this is an excellent program, it only works on Windows and is not extensible without modifying its C++ source. I am gradually building up the components in Py65 so that a similar type of program can be written on top of it without these limitations.
Regards,
Mike
- Mike Naberezny (mike@naberezny.com) http://6502.org
Quote:
I wrote the majority of the tests before attempting to run any non-trivial 6502 code
I had an idea that one could write code - perhaps automatically, derived from the py65 testsuite - which was self-checking, hitting a BRK if it found a flag or a value in a different state from that expected.
I see now that Rob Finch has already written such a self-checking program! His bc6502 includes test6502.a65 which starts by checking branch and compare and then going on to more interesting instructions. He's got 40+ tests in 1000 lines of assembly.
(The license may be problematic: revocable, only for education and evaluation, only distributable unmodified and in full. So no snippets from me.)
(Oddly though, py65 fails several of the tests. At least one looks like a real bug - filed!)