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

ZeroPage

STX zp

86 nn

3

ZeroPage+Y

STX zp,y

96 nn

4

Absolute

STX addr

8E ll hh

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)

See Also

  • LDA (LoaD Accumulator)

  • STA (STore Accumulator)

  • STY (STore Y register)

Comments