Testing instruction timings for 6502 emulators
Posted: Mon Jun 22, 2015 10:01 am
Elsewhere is a discussion about how to test that an emulator has the right instruction timings - Klaus' functional test suite isn't ideal for this although it could perhaps be a confidence test. Other representative code can also be a confidence test.
I thought it might be useful to have a test specifically for this purpose, so please see
https://github.com/BigEd/6502timing
and please let me know how you get on.
Until we find a way to run a test like this on a real 6502 and count the cycles, the best we can do is compare various emulators. In case of differences we can run subsets of the test, branch and bound until we find the first discrepancy.
Obviously, to compare we need to use the same version of the program, have no interrupts running, no stolen cycles with RDY, and account for all the instructions in the program and no more. Could be fiddly.
Assembly syntax is for Michal Kowalski's simulator as found at http://www.exifpro.com/utils.html because that was the easiest way to both assemble and get timings. Edit: but see below, the cycle count model in this simulator is not accurate.
Edit: summarised results for various models here.
Edit: attached a zipfile with source, listing, and a binary file.
Edit: updated the zipfile with changes to label syntax
Edit: here's the current version of the program in srec format - it's to be loaded and run at $1000
I thought it might be useful to have a test specifically for this purpose, so please see
https://github.com/BigEd/6502timing
and please let me know how you get on.
Until we find a way to run a test like this on a real 6502 and count the cycles, the best we can do is compare various emulators. In case of differences we can run subsets of the test, branch and bound until we find the first discrepancy.
Obviously, to compare we need to use the same version of the program, have no interrupts running, no stolen cycles with RDY, and account for all the instructions in the program and no more. Could be fiddly.
Assembly syntax is for Michal Kowalski's simulator as found at http://www.exifpro.com/utils.html because that was the easiest way to both assemble and get timings. Edit: but see below, the cycle count model in this simulator is not accurate.
Edit: summarised results for various models here.
Edit: attached a zipfile with source, listing, and a binary file.
Edit: updated the zipfile with changes to label syntax
Edit: here's the current version of the program in srec format - it's to be loaded and run at $1000
Code: Select all
S1231000A2FF9AA2018617861886168AA898BAAAA200A0000117051709000D1717111715F2
S1231020171D1717191717CA880117111715171D1717191717E8C82117251729002D17170B
S1231040311735173D1717391717CA882117311735173D1717391717A200A0004117451740
S123106049004D1717511755175D1717591717CA884117511755175D1717591717A200A0F0
S1231080006117651769006D1717711775177D1717791717CA886117711775177D171779EC
S12310A01717A200A000A901811785178D1717911795179D1717991717CA88811791179516
S12310C0179D1717991717A200A000A117A517A900AD1717B117B517BD1717B91717CA8871
S12310E0A117B117B517BD1717B91717A200A000C117C517C900CD1717D117D517DD171735
S1231100D91717CA88C117D117D517DD1717D91717A200A000E117E517E900ED1717F11772
S1231120F517FD1717F91717CA88E117F117F517FD1717F91717A200061746170E17174EF7
S12311401717161756171E17175E1717CA161756171E17175E1717A200261766172E1717F7
S12311606E1717361776173E17177E1717CA361776173E17177E1717A000A6178617AE1762
S1231180178E1717B6179617BE171788B6179617BE1717A200C617E617CE1717EE1717D6BA
S12311A017F617DE1717FE1717CAD617F617DE1717FE1717A2001002105C30FE10FAF00289
S12311C0F056D0FEF0FAA2FF3002304E10FE30FAD002D048F0FED0FA1890029041B0FE9029
S12311E0FA38B002B03A90FEB0FAB85002503370FE50FAA97F697F7002702950FE70FAC805
S123120088E8CAEA0A2A4A6A202612486808287858F8D84C3B1210A6F0AC30B4D0BA90C13C
S1231220B0C850CF70D9203412AD3312A20081176C17006068186901484840A20024172C92
S12312401717A4178417AC17178C1717B4179417BC1717CAB4179417BC1717C017C417CC6A
S10F12601717E017E417EC17174C0010E8