I have C code that looks something like this:
static const PROGMEM byte progdata[6] = {0x55, 0x3E, 0xBB, 0x21, 0x92, 0x02}; static byte testarray[6]; void testpgm() { testarray[0] = pgm_read_byte_near(progdata + 0); testarray[1] = pgm_read_byte_near(progdata + 1); testarray[2] = pgm_read_byte_near(progdata + 2); ... }
The resulting avr-gcc produced asm looks something like this:
ldi r30,lo8(progdata) r31,hi8(progdata) lpm r24, Z sts testarray,r24 adiw r30,1 lpm r24, Z sts testarray+1,r24 adiw r30,1 lpm r24, Z ...
I noticed that the address of progdata is copied directly into the Z register, unlike in Atmel asm which multiplies by 2. Based on the brne thread, I assume this is because GAS keeps byte addresses rather than 16 bit word addresses to progmem? But what if the address of progdata was used in an instruction that expected a word address? Does the conversion to word addressing happen on a per instruction basis?