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

ZeroPage

STA zp

85 nn

3

ZeroPage+X

STA zp,x

95 nn

4

Absolute

STA addr

8D ll hh

4

Absolute+X

STA addr,x

9D ll hh

5

Absolute+Y

STA addr,y

99 ll hh

5

(Indirect+X)

STA (zp,x)

81 nn

6

(Indirect)+Y

STA (zp),y

91 nn

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)

See Also

  • LDA (LoaD Accumulator)

  • STX (STore X register)

  • STY (STore Y register)

Comments