gameboy-doctor icon indicating copy to clipboard operation
gameboy-doctor copied to clipboard

Suggestion: Include last address and value written to by the CPU

Open JoseLGF opened this issue 6 months ago • 4 comments

Hello,

first of all, thank you for your amazing tool. It has truly saved me a lot of time! However, I am currently stuck because my emulator fails test 1 in line 16484, in instruction 0xF1 POP AF in the flags. Now, the POP instruction, as with many others, reads data from the memory, or bus. But if a previous instruction wrote an incorrect value to the memory, then it's not possible to know where it went wrong.

Therefore, I think it would be valuable to keep track the state of the memory that the CPU writes to. My idea is to extend the current log format with fields "LA", and "LV", which indicate if the last instruction executed wrote to memory, and what value was written. In case no value was written, the character '-' can be used.

JoseLGF avatar Jun 09 '25 03:06 JoseLGF

That does sound useful! It sounds a bit harder to instrument to me, and the example logs would have to be regenerated. I think we'd want a flag or some kind of other syntax for specifying which fields should be checked, in case someone didn't want to instrument LA and LV.

This said, if you were interested in adding it then I'd love to take a look!

robert avatar Jun 09 '25 05:06 robert

I have almost the same issue, and thus the same request :D Facing an issue where (HL) is XOR'd with A, giving different results. struggling to understand where things went wrong

toep avatar Jun 26 '25 15:06 toep

I also encountered the POP AF problem. I tried to print n values ​​in the stack to check manually, but I still couldn't find the problem.

UradaSources avatar Sep 15 '25 07:09 UradaSources

I also encountered the POP AF problem. I tried to print n values ​​in the stack to check manually, but I still couldn't find the problem.

Not related to this project, but for those who search for POP AF and come here, I debugged it for a day and finally figured it out. The lower 4 bits of F are always 0, so if you write 0x9B, it should be 0x90 when reading.

UradaSources avatar Sep 15 '25 08:09 UradaSources