BigEd wrote:
I notice that ONEBYTE is a logic signal inside the 6502 which
detects single-byte instructions (in order to
stop the PC from over-incrementing) and it fires for NOP, as you'd expect, but not for BRK.
So, internally, BRK is not a single-byte instruction - despite the original datasheet describing it as such. I think that's an error in the datasheet, because BRK behaves very like a software interrupt: it pushes the status byte, and behaves cycle-by-cycle like an NMI or IRQ. And so RTI feels like the right way to return, if one ever did, and the way that works most naturally is to regard BYTE as followed by an operand byte. We could perhaps call it a dummy operand, but we seem to have landed on calling it a signature byte - same thing to the 6502, as the 6502 ignores it.
I don't expect it would be able to use the single byte op-code process ... the second cycle of a single-byte instruction is followed by the execution of the following instruction, where the second cycle of BRK is followed by the 3rd cycle of the IRQ/NMI process. Or, at the very least, it's likely a saving of transistors to just let it do the normal PC increment at the end of the second cycle before entering the third cycle of the IRQ/NMI process. So the "signature" gets read, and is on the databus, but it's never used.
One "clean" use of the signature byte is to deliberately insert breakpoints / watchpoints in test code -- in the source, rather than over-writing a PROM -- where the signature byte may be the low address for a table of jump vectors. That is easier to use if the 64KB address space is not fully populated, so a shipping board might have 4KB of ROM but the test set-up has 8KB, which gives plenty of extra space for both the break points and the break point handling code, with only the IRQ pass-on vector and the break-point function vectors having to be in scarce RAM.
An elaboration of that is a test rig for a board that snoops the execution of a BRK and has hardware responses to the value of the signature byte when it is read in the second cycle of the BRK process.