6502.org Forum  Projects  Code  Resources  Tools  Forum  Log in
 
Search Search FAQ FAQ Members Members Profile Profile Log in to check your private messages Log in to check your private messages Register Register

who knows a full test code for 6502?

 
Post new topic   Reply to topic    6502.org Forum Index -> Programming
View previous topic :: View next topic  
Author Message
amin2312



Joined: 30 Jul 2009
Posts: 4

PostPosted: Tue Aug 04, 2009 3:07 am    Post subject: who knows a full test code for 6502? Reply with quote

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.
Back to top
View user's profile Send private message
BigEd



Joined: 11 Dec 2008
Posts: 397
Location: England

PostPosted: Tue Aug 04, 2009 7:49 am    Post subject: Reply with quote

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]
Code:
  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)


At the end of this 2006 thread "stable, tested 6502 core" (also found here) MikeJ says
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.

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.)
Back to top
View user's profile Send private message Visit poster's website
Mike Naberezny
Site Admin


Joined: 30 Aug 2002
Posts: 192
Location: Northern California

PostPosted: Tue Aug 04, 2009 7:47 pm    Post subject: Reply with quote

BigEd wrote:
If you can use (or convert) python, you might get some mileage out of the testsuite in Mike's py65 emulator.

Having good test coverage is one of the goals of the Py65 simulator. I wrote the majority of the tests before attempting to run any non-trivial 6502 code. After the tests were all passing, Py65 was able to run Lee's EhBASIC without any issues.

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://www.6502.org
Back to top
View user's profile Send private message Visit poster's website
BigEd



Joined: 11 Dec 2008
Posts: 397
Location: England

PostPosted: Thu Aug 06, 2009 6:36 pm    Post subject: Reply with quote

Quote:
I wrote the majority of the tests before attempting to run any non-trivial 6502 code


Excellent!

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!)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    6502.org Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum