Syntax: |
Operation: |
Operands: |
Program Counter: |
Opcode |
Comment: |
Stack |
ST Z, Rr |
DS(Z) =Rr |
0 <= r <= 31 |
PC = PC + 1 |
1000001rrrrr0000 |
Z: Unchanged |
|
ST Z+, Rr |
DS(Z) = Rr, Z = Z+1 |
0 <= r <= 31 |
PC = PC + 1 |
1001001rrrrr0001 |
Z: Post incremented |
|
ST -Z, Rr |
Z = Z - 1, DS(Z) = Rr |
0 <= r <= 31 |
PC = PC + 1 |
1001001rrrrr0010 |
Z: Pre decremented |
|
STD Z+q, Rr |
DS(Z+q) = Rr |
0 <= r <= 31, 0 <= q <= 63 |
PC = PC + 1 |
10q0qq1rrrrr0qqq |
Z: Unchanged, q: Displacement |
Stores one byte indirect with or without displacement 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 Z (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 RAMPZ in the register in the I/O area has to be changed.
The Z-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 Stack Pointer usage of the Z-Pointer Register. However, because the Z-Pointer Register can be used for indirect subroutine calls, indirect jumps, and table look-up, it is often more convenient to use the X- or Y-pointer as a dedicated Stack Pointer. Note that only the low byte of the Z-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 RAMPZ 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/displacement 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 Z+, r30
ST Z+, r31
ST -Z, r30
ST -Z, r31
Using the Z-pointer:
I |
– |
||
T |
– |
||
H |
– |
||
S |
– |
||
V |
– |
||
N |
– |
||
Z |
– |
||
C |
– |
clr r31 ; Clear Z high byte ldi r30,0x60 ; Set Z low byte to 0x60 st Z+,r0 ; Store r0 in data space loc. 0x60(Z post inc) st Z,r1 ; Store r1 in data space loc. 0x61 ldi r30,0x63 ; Set Z low byte to 0x63 st Z,r2 ; Store r2 in data space loc. 0x63 st -Z,r3 ; Store r3 in data space loc. 0x62(Z pre dec) std Z+2,r4 ; Store r4 in data space loc. 0x64
1 (2 bytes)
Name |
Cycles (i) |
(ii) |
(iii) |
(iv) |
AVRe |
2(1) |
2(1) |
2(1) |
2(1) |
AVRxm |
1(1) |
1(1) |
2(1) |
2(1) |
AVRxt |
1(2) |
1(2) |
1(2) |
1(2) |
AVRrc |
1 |
1 |
2 |
N/A |
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.