Page 1 of 1

Op-code testing

Posted: Mon Oct 18, 2004 12:27 pm
by petej
Can any of you 65(C)02 emulator/simulator writers out there point me in the direction of some well-established code that will allow me to test out all the standard op-codes? Presumably, you must have tested your emulator/simulator on such code?

I'd like to obtain a dump of of the PC and A,X,Y,P,S values after each instruction so I can check if my model is working correctly.

Posted: Tue Aug 02, 2005 9:56 pm
by Raf
http://www.serious-dial.atari.pl/pliki/ ... r_6502.zip

try this book, in the least part there are some short codes with very detailed description what's going on and how registers are set

Posted: Thu Aug 04, 2005 1:53 am
by Goog
I, too, am writing an emulator and need opcode test cases - would prefer it if they were self-testing (pass/fail with no user interaction), but I can step through each if necessary.

I checked out the link that Raf posted, but it seems to be in a format I am not familiar with.

Would appreciate any tests.

Posted: Thu Aug 04, 2005 4:04 pm
by Raf
I think that people out there can write small portions of code just to test various intructions and then if you put it all together you'll have such a test code. Myself I write such a small thingies to test if I'm thinking good about it's functionality in Michal Kowalski's 6502 simulator.

let's start with LDA: it affects only Z and C in that way:

lda #0 -> Z=1
lda #128 or higher -> N=1

CMP : if argument for cmp is greater than or equal to akku then C=1 N=0 else C=0 N=1 , if operand = akku then Z=1
live things:
LDA #20
CMP #20 -> C=1 , Z=1 , N=0

LDA #10
CMP #20 -> C=0 , Z=0 , N=1

LDA #20
CMP #10 -> C=0 , Z=0 , N=1

too bad somewhere I've had a chart which clearly showed which instructions affects bits in cpu's register but I just lost it. I have similiar thing in book but it's in polish :)

Posted: Thu Aug 04, 2005 8:07 pm
by Goog
I'm not saying that I cannot write such tests, I just don't want to - it is work enough having to write the emulator, so I was hoping that there would be tests that people have used already that they can share with emulator writers, such as myself.

If I don't find anything that is already self-contained and complete, I'll just have to write them all myself.

Posted: Fri Aug 05, 2005 7:48 am
by Raf
I see :) then don't rely on me ;-) I'm too lazy to write such a thing :P

Re: Op-code testing

Posted: Thu Aug 18, 2005 3:12 am
by asmlang_6
petej wrote:
Can any of you 65(C)02 emulator/simulator writers out there point me in the direction of some well-established code that will allow me to test out all the standard op-codes? Presumably, you must have tested your emulator/simulator on such code?

I'd like to obtain a dump of of the PC and A,X,Y,P,S values after each instruction so I can check if my model is working correctly.
I might be able to write that, but I need to know something: do you want to test all opcodes of the NMOS 6502 (including undocumented ones), just the documented ones, or the ones of the 65C02?

Posted: Thu Aug 18, 2005 6:23 pm
by petej
The most interesting one I found was by Wolfgang Lorenz. He wrote a C64 emulator some time ago. If you google for something like "wolfgang lorenz 6502 test suite" you should be able to track down his testsuite-2.1x.tar.gz code.

It needs work to make it run on Kowalski's emulator as it uses C64 bios calls to chain in further segments of code. If you make any progress with it let us know.

Posted: Thu Aug 18, 2005 6:37 pm
by petej
Goog,

I don't want to dampen your enthusiasm for writing yet another 6502 simulator, but there are lots of them already out there. The source code for Kowalski's is on his web site.

I'm not aware of there being one of the same quality of Kowalski's for the 65802/65816 instruction set. There are ones for the SNES but, from my cursory Google, not in the same league as Michal's which I've sucessfully used to test out my code before running it on real 65C02-based hardware.

A 65816 simulator/emulator extension for Kowalski's would get my vote :wink:

Posted: Sat Jul 19, 2008 6:37 pm
by bruce_lee
thanks alot guys appreciate it :D