This is the mail archive of the 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

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".


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:


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