I'm not certain if I found an anomaly or if I'm doing something wrong. In some recent testing, I've noticed that the BRK bit is being set in the processor status register on a PLP, but the byte it pulls is a $00. Code is simple enough, I invoke code via a CNTRL key (to limit any other code interfering) to run a small routine. Note: CPU is W65C02S.
Code:
;Break test - invoked by CNTRL-Y
BRKTEST ;Test theory on BRK flag being set on PHY/PLP with zero pushed on the stack
LDY $04FE ;Load Y reg with value from RAM
PHY ;Push it to the stack
PLP ;Pull it to the Processor status reg
PHP ;Push it back to the stack
PLX ;Pull it to X reg
STX $04FF ;Store it in memory for viewing
RTS ;Return to caller
Regardless of how I load $04FE, the result in $04FF always shows the BRK bit being set. I searched around and haven't found this documented anywhere. Also, I have a routine in my BIOS which handles a software break (send a null character to the board). This is handled correctly and the BRK bit is not set. Executing code which does execute a BRK instruction does set the BRK flag. The unused status bit (emulation bit for the 65C816) always shows as set when testing the processor status which is normal. I also have a full ISR that handles both HW interrupts and the BRK instruction and this works correctly. Has anyone else noticed this odd behavior?