6.68.1 Description

Loads one byte indirect with or without displacement from the data space to a register. 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.

In the Reduced Core AVRrc, the LD instruction can be used to achieve the same operation as LPM since the program memory is mapped to the data memory space.

For using the Z-pointer for table look-up in program memory, see the LPM and ELPM instructions.

The result of these combinations is undefined:

LD r30, Z+

LD r31, Z+

LD r30, -Z

LD r31, -Z

Using the Z-pointer:

Operation:

Comment:

(i)

Rd ← DS(Z)

Z: Unchanged

(ii)

Rd ← DS(Z), Z ← Z + 1

Z: Post incremented

(iii)

Z ← Z - 1, Rd ← DS(Z)

Z: Pre decremented

(iv)

Rd ← DS(Z+q)

Z: Unchanged, q: Displacement

Syntax:

Operands:

Program Counter:

(i)

LD Rd, Z

0 ≤ d ≤ 31

PC ← PC + 1

(ii)

LD Rd, Z+

0 ≤ d ≤ 31

PC ← PC + 1

(iii)

LD Rd, -Z

0 ≤ d ≤ 31

PC ← PC + 1

(iv)

LDD Rd, Z+q

0 ≤ d ≤ 31, 0 ≤ q ≤ 63

PC ← PC + 1

16-bit Opcode:

(i)1000000ddddd0000
(ii)1001000ddddd0001
(iii)1001000ddddd0010
(iv)10q0qq0ddddd0qqq