mnaberez / py65

Emulate 6502-based microcomputer systems in Python
BSD 3-Clause "New" or "Revised" License
234 stars 68 forks source link

Add ability to save/restore machine state snapshot #43

Open mnaberez opened 6 years ago

mnaberez commented 6 years ago

Suggested by @scotws over in #40:

The one thing I had been wondering about is a way to freeze and load the complete machine state, something like a snapshot in VirtualBox -- not only save the memory, but also the registers, etc. That way, you could add a "freezepoint" -- like a breakpoint -- that saves the machine state to a given file when the machine reaches there, and then could do an extensive postmortem externally -- look at the stack, for instance.

The relevance for testing would be that you could start by loading a known state ("have"), run the simulator from a certain address onwards, freeze the state at some point, and then compare it automatically to a target state ("want").

That would, of course, require some easy to use format for the frozen state, but with the small sizes we're talking about here -- 64 Kib and change -- I wonder if you could get away with some compressed form of JSON.