From: David Brown <david.brown@hesbynett.no>
To: "Łukasz Kostka" <lukasz.kostka@netng.pl>, gcc@gcc.gnu.org
Subject: Re: AVR __progmem__ variable reading
Date: Sat, 23 Feb 2019 15:34:00 -0000 [thread overview]
Message-ID: <d3f6b579-0fe0-0f97-1438-79c10e88bb96@hesbynett.no> (raw)
In-Reply-To: <AA53195D-2F98-4CEA-A012-54ADD8C7CCB1@netng.pl>
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>
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>
next prev parent reply other threads:[~2019-02-23 15:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 22:34 Łukasz Kostka
2019-02-23 15:34 ` David Brown [this message]
2019-02-23 18:38 ` Łukasz Kostka
2019-02-24 11:13 ` David Brown
2019-02-24 13:47 ` Łukasz Kostka
2019-02-24 13:58 ` David Brown
2019-02-24 17:29 ` Łukasz Kostka
2019-02-25 7:43 ` David Brown
2019-02-25 17:09 ` Łukasz Kostka
2019-02-25 17:19 ` David Brown
2019-02-25 19:32 ` Łukasz Kostka
2019-02-26 6:05 ` SenthilKumar.Selvaraj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d3f6b579-0fe0-0f97-1438-79c10e88bb96@hesbynett.no \
--to=david.brown@hesbynett.no \
--cc=gcc@gcc.gnu.org \
--cc=lukasz.kostka@netng.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).