Operations:

Syntax:

Operation:

Operands:

Program Counter:

Opcode

Comment:

Stack

ST X, Rr

DS(X) = Rr

0 <= r <= 31

PC = PC + 1

1001001rrrrr1100

X: Unchanged

ST X+, Rr

DS(X) = Rr, X = X+1

0 <= r <= 31

PC = PC + 1

1001001rrrrr1101

X: Post incremented

ST -X, Rr

X = X - 1, DS(X) = Rr

0 <= r <= 31

PC = PC + 1

1001001rrrrr1110

X: Pre decremented

Description

Stores one byte indirect from a register to data space. The data space usually consists of the Register File, I/O memory, and SRAM, refer to the device data sheet for a detailed definition of the data space.

The data location is pointed to by the X (16-bit) Pointer Register in the Register File. Memory access is limited to the current data segment of 64 KB. To access another data segment in devices with more than 64 KB data space, the RAMPX in the register in the I/O area has to be changed.

The X-Pointer Register can either be left unchanged by the operation, or it can be post-incremented or pre- decremented. These features are especially suited for accessing arrays, tables, and Stack Pointer usage of the X-Pointer Register. Note that only the low byte of the X-pointer is updated in devices with no more than 256 bytes of data space. For such devices, the high byte of the pointer is not used by this instruction and can be used for other

purposes. The RAMPX Register in the I/O area is updated in parts with more than 64 KB data space or more than 64 KB program memory, and the increment/ decrement is added to the entire 24-bit address on such devices.

Not all variants of this instruction are available on all devices.

The result of these combinations is undefined:

ST X+, r26

ST X+, r27

ST -X, r26

ST -X, r27

Using the X-pointer:

Status Register (SREG) and Boolean Formula

I

T

H

S

V

N

Z

C

Example:

      clr   r27        ; Clear X high byte
      ldi   r26,0x60   ; Set X low byte to 0x60
      st    X+,r0      ; Store r0 in data space loc. 0x60(X post inc)
      st    X,r1       ; Store r1 in data space loc. 0x61
      ldi   r26,0x63   ; Set X low byte to 0x63
      st    X,r2       ; Store r2 in data space loc. 0x63
      st    -X,r3      ; Store r3 in data space loc. 0x62(X pre dec)

Words

1 (2 bytes)

Table Cycles

Name

Cycles

(i)

(ii)

(iii)

AVRxm

1(1)

1(1)

1(2)

AVRxt

1(2)

1(2)

1(2)

AVRrc

1

1

2

AVRe

2(1)

2(1)

2(1)

Notes:

1.

Cycle times for data memory access assume internal RAM access and are not valid for accessing external RAM.

2.

Cycle time for data memory access assumes internal RAM access, and are not valid for access to NVM. A minimum of one extra cycle must be added when accessing NVM. The additional time varies dependent on the NVM module implementation. See the NVMCTRL section in the specific devices data sheet for more information.