Hello,
first of all I really love this project. I use it to simulate/trace the program code of an old dmx light controller (MA LightCommander 12/2) which uses the MC68008, reading the assembly is one thing but it is much nicer to let it run and actually see how it works.
To trace memory access better I tried to find a way to somehow get the current program counter in the read and write methods of Addressable devices, to be able to print out not only what address was read or written but also from where in the program it took place.
Sadly, after multiple tries I did not succeed in finding a good way, so I am now asking you if you have a suggestion how to make it work.
I tried adding a write with program counter command to run_command
of the M68k, however to use it I would need mutable access to system in my device, which I couldn't make work.
Then I tried storing the log message in the device and call a print out method after every step with the current program counter, however that needs access to the cpu outside of the device, which I was unable to get without unsafe casting from the device.
Additionally I thought about adding a new error type which would add the program counter to the inner string, but that also stops the execution of the cpu, which I wanted to avoid.
My final idea (which I haven't tried yet) would be to instead of clock add a context variable to the read and write methods. It would be passed by reference through all addressable methods that currently have clock. The context variable would be a struct with at least the program counter and the clock in them. It would be created in the cpu on read/write and passed through every addressable in the chain (M68kBusPort -> Bus -> Any addressable device)
That way and device that supports addressable can also log some access information if it needs to. It could also help to create better error messages when a read/write address is outside of the valid segments
If this idea sounds workable to you I'm happy to write a PR as well
Best, Jomer