STA (STore Accumulator)¶
[operand] = A
The STA instruction transfers the contents of the accumulator register (A) to the specified memory location. The operand specifies the memory location where the data is to be stored.
Addressing Modes¶
Mode |
Syntax |
Bytes |
Cycles |
---|---|---|---|
STA zp |
|
3 |
|
STA zp,x |
|
4 |
|
STA addr |
|
4 |
|
STA addr,x |
|
5 |
|
Absolute+Y |
STA addr,y |
|
5 |
STA (zp,x) |
|
6 |
|
STA (zp),y |
|
6 |
Flags Affected¶
None.
Examples¶
Storing a Value to a Memory Location¶
LDA #10 ; load A with constant 10
STA $40 ; store the value of A to memory location $40
Storing the Accumulator to an Absolute Address¶
STA $2000 ; store the value of A to memory location $2000
Storing the Accumulator to a Zero-Page Address¶
STA $40 ; store the value of A to memory location $40
Storing the Accumulator to an Address Indexed by X¶
LDA #10 ; load A with constant 10
LDX #2 ; load X with constant 2
STA $40,X ; store the value of A to memory location $42 (assuming X = 2)