Hi!
Procrastin8 wrote:
Hello, world! I wrote an all Swift 65C02 simulator and am trying to run the Klaus functional tests. Most of it runs quite fast (I think?) but the comprehensive ADC/SBC section is taking an enormous amount of time. I tried to run the tests against lib6502 just as a baseline but was unsuccessful in getting it to run the tests at all. I have been running it for 9 min so far and it has only gone up to 178 on op2.
Some baselines just to make sure I'm doing this correctly:
- I execute 409 instructions on each innerloop from 0x3345 -> 0x3345 (this is incrementing op1)
- I execute ~103k instructions on each outerloop from 0x335F -> 0x335F (this is incrementing op2)
It takes ~6 seconds per outerloop iteration. So 256 * 6sec = ~1500sec (25 min!) to execute the test. I thought i read somewhere though their implementation ran in 52 seconds! That seems insane (ly good)!
Is my implementation just waaaay off?
IMHO, your emulator is really slow.
My stats for the Klaus 6502 test:
Code:
Total Cycles: 96243729
Total Instructions: 30646866
Total Branches: 5206450 (17.0% of instructions)
Total Branches Taken: 258795 (5.0% of branches)
Branches cross-page: 285 (0.1% of taken branches)
Absolute X cross-page: 302152
Absolute Y cross-page: 302152
Indirect Y cross-page: 302148
That includes 5 extra cycles for my the emulator exit - a "JMP (DOS)".
My emulator executes all 30M instructions in 0.25 seconds here, or if I enable tracing (that writes each disassembled executed instruction to a log file) it takes 1.8 seconds.
A 2MHz 6502, without any wait states, should complete the test in 96243729 / 2000000 = 48.12 seconds.
Have Fun!