blackjetrock / z80_shield

Z80 Shield project
27 stars 7 forks source link

Register dump in middle of instruction #20

Closed blackjetrock closed 4 years ago

blackjetrock commented 4 years ago

The register dump uses injection of code between instructions. This means that it must run between instructions. This isn't the case if a prefix opocde has just been executed. At the moment the 'n' command stops when it sees M1 asserted (next instruction about to start). the prefix opcodes (like 0xdd) assert M1, then the normal following instruction that they are modifying also asserts M1. So the 'n' command stops on prefix instructions. If you press 'g' after the prefix opcode then the prefix is applied to the first instruction of the injected code. This mucks up the injected code and also the running code as the prefix opcode is not executed for the following instruction as it has been 'used up' on the injected code.

The fix is for the 'n' (and maybe 'g') commands to be more intelligent about when the 'n' command stops (or the 'g' command starts, maybe). So, 'n' should only stop when it's safe for 'g' to run. This has the nice side effect that 'n' runs entire instructions including prefix and following instruction.