MichaelM wrote:
Alarm Siren:
Perhaps I'm missing something, but the process that you describe for interrupting a burst mode MVN/MVP does not seem to account for the need to adjust the PC to point back to the instruction itself in order to restart it after the interrupt service routine completes and returns. After fetching the instruction and its two immediate operands, the PC should be pointing to the first byte of the next instruction.
Unlike the BRK trap service routine, which has a way of identifying the BRK trap in P on the stack, an interrupted MVN/MVP instruction does not provide any special markers to allow the NMI / IRQ service routines to make the required adjustment to the stacked PC. On a 6502/65C02 processor, adjusting the stacked return address to that of the instruction following a BRK requires an non-trivial amount of code in the service routine. The stack-relative addressing mode of the 65816 makes this process much easier and efficient, but the service routine would need to somehow know that it was reached by interrupting the MVN/MVP instruction in order to back up the stacked PC value by 3.
I don't see that this would be an issue. 6502 does not interrupt within an instruction, only between them. If each loop of the MVx instruction is treated as an "instruction", with the psuedo-conditional branch at the end considered the end of the instruction, then PC will be correctly reset back to the MVx opcode before an interrupt is allowed to fire, so the values saved on the stack will also be correct.
BigEd wrote:
(Just a thought: if the last thing MVN/MVP do is a bit like a branch, would we expect the final non-branching iteration to take one fewer cycle? If the MVN/MVP instruction spans a page boundary, would we expect an extra cycle each time around??)
I'm not sure. It depends on how well they might be able to utilise internal datapaths; they might be able to do the PC calculation during other cycles and then just "throw it away" at the end if the branch isn't taken. The datasheet doesn't show one less cycle for the final iteration, nor does it show extra cycles for a page boundary. I would be very interested to know the bus activity in these circumstances, if someone felt like testing a 65816 (I don't own any, nor the equipment to test the bus in that way).
_________________
Want to design a PCB for your project? I strongly recommend
KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of
Retro Computing and
Arduino components you might find useful.