CPU status flag behavior

From NESdev Wiki
Jump to navigationJump to search

The status register doesn't implement bits 4 and 5. The only way to test those bits would be to push the status on the stack, but any time the status is pushed on the stack, those bits are set to fixed values, as described below.

When an IRQ or NMI occurs, the current status with bit 4 clear and bit 5 set is pushed on the stack, then the I flag is set.

PHP and BRK push the current status with bits 4 and 5 set on the stack; BRK then sets the I flag.

RTI and PLP set the status to the byte popped off the stack.