stardot / b-em

An opensource BBC Micro emulator for Win32 and Linux
http://stardot.org.uk/forums/viewtopic.php?f=4&t=10823
GNU General Public License v2.0
112 stars 56 forks source link

ARM tracing incorrect #185

Closed rjpontefract closed 1 year ago

rjpontefract commented 1 year ago

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);
rjpontefract commented 1 year ago

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.

SteveFosdick commented 1 year ago

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

rjpontefract commented 1 year ago

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.

SteveFosdick commented 1 year ago

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

rjpontefract commented 1 year ago

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.

SteveFosdick commented 1 year ago

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.

rjpontefract commented 1 year ago

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