STY Instruction (Store Index Register Y to Memory)
Writes the value of index register Y to the specified address in memory.
STY Overloads
| Opcode | Syntax | Addressing mode | Bytes | Cycles | Notes |
|---|---|---|---|---|---|
| 84 | STY dp | DP. | 2 | 3 | 1, 2 |
| 94 | STY dp, X | DP. Idx X | 2 | 4 | 1, 2 |
| 8C | STY abs | Abs. | 3 | 4 | 1 |
Notes
- Add 1 cycle when the index flag is clear.
- Add 1 cycle when the direct page start address is not on a page boundary.
Flag changes
--------
This instruction does not change the status flags.
Explanation
The STY instruction writes the value of index register Y to memory according to the addressing mode specified by the opcode.
When the index flag in the status register is clear, it writes 16-bit data; when the index flag is set, it writes 8-bit data.
Data is written in little-endian order. That is, in memory the low byte always comes first.
Examples
Saving a value
STY $12 ; save Y to $12
The only indexed mode available for STY is dp,X.
See also
LDA Instruction
LDX Instruction
LDY Instruction
STA Instruction
STX Instruction
STY Instruction
STZ Instruction