Hello,
LDS (16-bit version) is defined as 1010 0kkk dddd kkkk (big endian)
and
LDD (using Z-pointer with displacement) is defined as 10q0 qq0d dddd 0qqq (big endian)
Now given following opcode
0xa400 (big endian) in hexadecimal and 1010 0100 0000 0000 (big endian) in binary,
this might be
lds r16, 0x20 because of 1010 0100 0000 0000 (0xa400) 1010 0kkk dddd kkkk (LDS 16-bit) and ADDR[7:0] := (¬INST[8], INST[8], INST[10], INST[9], INST[3], INST[2], INST[1], INST[0]) ==> ADDR[7:0] = 2^5 (INST[10] = 1) = 32 = 0x20 and r16 because of dddd = 0, with 16 <= d <= 31 ==> rd = 16
but the same opcode might be
ldd r0, Z+40 because of 1010 0100 0000 0000 (0xa400) 10q0 qq0d dddd 0qqq (LDD, Z + disp.) so q = 2^3 + 2^5 = 40 (decimal) ==> Z+40 and d = 0 ==> rd = r0
Now "ldd r0, Z+40" and "lds r16, 0x20" are obviously not the same instruction.
The only way in which this collision can not cause problems would be that both instructions are never supported by a microcontroller at the same time.
Does anyone know more ?