PHP Instruction (Push Processor Status Register)
Pushes the processor status register onto the stack.
PHP Overloads
| Opcode | Syntax | Addressing mode | Bytes | Cycles | Notes |
|---|---|---|---|---|---|
| 08 | PHP | Stack | 1 | 3 |
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