rosco-m68k / rosco_m68k

Design, documentation and software for the Really Old School Computer (M68K)
https://rosco-m68k.com
Other
157 stars 32 forks source link

Fix debug trap handler beyond MC68010 #418

Closed 0xTJ closed 5 months ago

0xTJ commented 6 months ago

This PR fixes #417 by adding cases to debug_stub for exception formats other than MC68000 and MC68010. If it is one of the exceptions that has a fault address (determined according to which handler was entered, as before) the code has a series of checks to select the current location in the exception stack frame to print as the fault address.

First it checks the SDB for CPU type, since MC68000 isn't compatible with the format of the others, the it checks the format field in the stack frame. Based on these checks, it branches to one of three instructions (MC68000/MC68010, MC68020/MC68030, and MC68040) to copy the fault address to the correct spot on the stack.

I'm open to feedback on how it's been implemented, and thoughts on if the different formats should use a table of offsets instead.

This has only been tested on MC68010.