dj-on-github / py6502

A Python 6502 Assembler/Disassembler/simulator in which python serves in place of the a macro language.
BSD 2-Clause "Simplified" License
32 stars 6 forks source link

Cycle counting #8

Open TobyLobster opened 2 years ago

TobyLobster commented 2 years ago

After executing some 6502 code, add the ability to read the number of cycles elapsed. Assuming it's not already done? I want to compare different versions of 6502 routines for efficiency.

dj-on-github commented 2 years ago

Line 4905 of sim6502.py in the execute function is where it indexes into the hexcodes list to get the instruction and address mode. You can add the cycles to the hexcodes table and add a flag for the page boundary extra cycle for the instructions where that happens and accumulate in the execute function. Feel free to have a go - I'm kinda busy right now so it'll be a while if you're waiting for me to do it.