| The B flag doesn't exist! :)|
Learned something interesting about the B "flag" recently. We all know that there are no CLB, SEB instructions to clear or set the B flag or any branch instructions to test it. The only way to inspect B is pushing the status register to the stack with PHP. Opps, but PHP always pushes B=1! BRK also pushes B=1 to the stack (naturally) and hardware interrupts push B=0, so we can distinguish between them in the interrupt handler by checking what is on the stack.
So, I suspected that there are no physical representation of the B flag in the CPU and it's state is not stored at all. It's just that for hardware interrupts B=0 is pushed on the stack, and that's all.
I turned out to be right, you can learn more about it on the excellent visual6502.org wiki:
Btw, I am writing a small python 6502 emulator what I will use in my projects to test/profile (maybe disassembly) machine code, it's early stage, but you can find it here: