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