I have been porting some inline assembler code that uses lpm to access the nvm, from AS 6.2 to 7.0.
uint8_t nvm_read_product_sig_row_a(uint16_t offset)
(void)offset; // Suppress unused parameter warning, doesn't do anything (thanks, stack overflow)
NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;
asm volatile ( "lpm %0, %a1":"=r"(w_value_lo):"e"(offset) ); // r18 is w_value_lo
// NVM_CMD = NVM_CMD_NO_OPERATION_gc;
Compiler is well behaved and produces the code below which is as good as it gets.
1ae2: 22 e0 ldi r18, 0x02 ; 2
1ae4: 20 93 ca 01 sts 0x01CA, r18 ; 0x8001ca <__TEXT_REGION_LENGTH__+0x7001ca>
1ae8: fc 01 movw r30, r24
1aea: 84 91 lpm r24, Z
1aec: 08 95 ret
I uncomment the line in bold above and I get the error "pointer register Z required' from the assembler.
This happens in Atmel studio 7. 6.2 produces the the assembler correctly..
1af2: 22 e0 ldi r18, 0x02 ; 2
1af4: 20 93 ca 01 sts 0x01CA, r18
1af8: fc 01 movw r30, r24
1afa: 84 91 lpm r24, Z
1afc: 10 92 ca 01 sts 0x01CA, r1
1b00: 08 95 ret
I have tried replacing the commented line with the assembler that is produced by Studio 6.2 into the 7.0 build
asm volatile ( "sts %0, r1":"=m"(NVM_CMD));
..and still get the error. It seems associated with the lpm statement.
Cannot make sense of this. Is there anyone with some experience of inline assembler that might have any idea?
Thanks for the help.