stardot/b-em

ARM tracing incorrect

rjpontefract opened this issue · 7 comments

When tracing is enabled in the debugger for the ARM co-processor, the traced instructions don't seem to take into account pipelining and the trace appears incorrect. Looking at the code, it seems that:

 if (arm_debug_enabled)
                    debug_preexec(&tubearm_cpu_debug, PC);

should possibly be:

 if (arm_debug_enabled)
                    debug_preexec(&tubearm_cpu_debug, PC - 8);

I also found that the ARM trace output is truncated due to returning strlen(buf). As buf is incremented when adding the PSR flags the length returned will always be 5 as that's the length of the final sprint() that is added.

The strlen() call should use the address of buf that is passed to arm_dbg_reg_print() originally not the value as modified by the function.

I have pushed a couple of fixes that should resolve these two issues.

Fantastic, thanks for the fixes.

I've been porting the BeebEm emulation of Sprow's ARM7TDMI co-processor to b-em, hence the interest in ARM.

Would there be any interest in including it in the official b-em repository as a branch maybe? I do have permission to include the ROM with b-em in return for an attribution and link to his website.

Yes, by all means add that. B-Em has a good range of tube processors including the unofficial ones so it fits right in.

I have a branch with the code for ARM7TDMI support in my fork of b-em at https://github.com/rjpontefract/b-em. The branch is rp/sprow_copro.

It builds and runs the various demonstration programs correctly. It even runs DudleySoft's port of Doom if you set the tube speed high enough.

I can create a pull request, but I don't want to mess it up, so any advice on how best to create a pull request would be appreciated.

I don't remember doing a pull request - as I have direct access to the repository I just work on a branch and merge when ready. But, looking at the network graph your fork has the latest master merged so it should merge cleanly. I would just follow the prompts from GitHub.

I've created a pull request for the changes. Let me know if there are any problems with it.