6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 2:09 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Aug 04, 2009 3:07 am 
Offline

Joined: Thu Jul 30, 2009 4:46 am
Posts: 4
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 04, 2009 7:49 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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.)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 04, 2009 7:47 pm 
Offline
Site Admin
User avatar

Joined: Fri Aug 30, 2002 1:08 am
Posts: 281
Location: Northern California
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://6502.org


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 06, 2009 6:36 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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!)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


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 post attachments in this forum

Search for:
Jump to: