PHA Instruction (Push Accumulator)
Pushes the accumulator onto the stack.
PHA Overloads
| Opcode | Syntax | Addressing mode | Bytes | Cycles | Notes |
|---|---|---|---|---|---|
| 48 | PHA | Stack | 1 | 3 | 1 |
Notes
1: Add 1 cycle when the memory mode flag is clear.
Flag changes
--------
This instruction does not change the status flags.
Explanation
The PHA instruction pushes the contents of the accumulator onto the stack. It pushes 2 bytes in 16-bit mode and 1 byte in 8-bit mode.
Examples
Saving A temporarily
PHA ; save A
JSR Sub ; a subroutine that destroys A
PLA ; restore A
If the width of A differs between pushing and pulling, the stack position gets out of step. Always execute PHA and PLA with the same width.
See also
PEA Instruction
PEI Instruction
PER Instruction
PHB Instruction
PHD Instruction
PHK Instruction
PHP Instruction
PHX Instruction
PHY Instruction
PLA Instruction
PLB Instruction
PLD Instruction
PLP Instruction
PLX Instruction
PLY Instruction