PHP Instruction (Push Processor Status Register)

Pushes the processor status register onto the stack.

PHP Overloads

OpcodeSyntaxAddressing modeBytesCyclesNotes
08PHPStack13

Flag changes

--------

This instruction does not change the status flags.

Explanation

The PHP instruction pushes the contents of the status flags onto the stack. Regardless of the processor’s operating mode, it always pushes an 8-bit value.

Examples

Preserving register widths in a subroutine

Sub:
    PHP             ; save the caller's flags (including register widths)
    REP #$30        ; this routine works in 16 bits
    ...
    PLP             ; restore the caller's register widths
    RTS

This makes the routine work correctly whatever widths the caller uses.

See also

PEA Instruction
PEI Instruction
PER Instruction
PHA Instruction
PHB Instruction
PHD Instruction
PHK Instruction
PHX Instruction
PHY Instruction
PLA Instruction
PLB Instruction
PLD Instruction
PLP Instruction
PLX Instruction
PLY Instruction