This is the mail archive of the
mailing list for the GCC project.
Re: AVR __progmem__ variable reading
> Wiadomość napisana przez David Brown <firstname.lastname@example.org> w dniu 23.02.2019, o godz. 16:34:
> On 22/02/2019 23:34, Łukasz Kostka wrote:
>> 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".
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:
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>