This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AVR __progmem__ variable reading



> Wiadomość napisana przez David Brown <david.brown@hesbynett.no> w dniu 23.02.2019, o godz. 16:34:
> 
> On 22/02/2019 23:34, Łukasz Kostka wrote:
>> Hi
>> I am using for a while now gcc and especially __progmem__ attribute. I’d like to report a feature request for gcc to handle reading from flash memory variables. Compiler has all the knowledge (target device, availability of LPM, ELPM instructions etc.) in order to properly interpret variable is accessed (eg. by array subscription).
>> This would remove need for any assembly code written to do this.
>> Make user code much cleaner.
>> GCC having all this knowledge can optimize end assembly code.
>> Simple attribute addition will switch from array in memory to array in flash.
>> Can serve as future implementations for other platforms.
>> What do you think ?
> 
> You don't need to write assembly to read flash data with AVR gcc - you have never needed it.  To use the "progmem" attribute, include the <avr/pgmspace.h> header and use the macros and functions from there, such as "pgm_read_byte".
> 
> <https://www.nongnu.org/avr-libc/user-manual/pgmspace_8h.html>
That is my point. I still need to use "ppm_read_byte" 
> 
> 
> Newer versions of AVR gcc have named address spaces, making the process simpler.  I must admit I haven't written any AVR code since these were added to the compiler, but I assume they work fine:
> 
> <https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#Named-Address-Spaces>
> 
Thx. I didn’t read this before. This works only for C. I use C++ and there are no named address spaces extensions :-(

My end goal is to use all variables in exactly same way as in regular code without <arv/pgmspace.h>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]