[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [avr-libc-dev] eeprom_read_word causes problems for the compiler

From: Haase Bjoern (PT/EMM1)
Subject: AW: [avr-libc-dev] eeprom_read_word causes problems for the compiler
Date: Mon, 15 Oct 2007 09:11:23 +0200

>Yes I will try to put together a patch with the minimal changes. I only
>to know one thing; can I assume that using this construction:
>/** \ingroup avr_eeprom
>    Read one 16-bit word (little endian) from EEPROM address \c addr.
>eeprom_read_word (const uint16_t *addr)
>  register uint16_t result asm("r24"); //I can specify r24 only
>  __asm__ __volatile__ (
>        XCALL " __eeprom_read_word_" _REG_LOCATION_SUFFIX CR_TAB
>       : "+x" (addr),
>         "=w" (result) //Use w restrict to adiw capable registers
>       : );
>  return result;

I fear that this will not be guaranteed to be correct! The compiler
might reorder code and might be tempted to optimize away your result
variable so that it could be placed in another register. The dangerous
thing is, that your code might work sometimes!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]