public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Łukasz Kostka" <lukasz.kostka@netng.pl>
To: David Brown <david.brown@hesbynett.no>
Cc: gcc@gcc.gnu.org
Subject: Re: AVR __progmem__ variable reading
Date: Sat, 23 Feb 2019 18:38:00 -0000	[thread overview]
Message-ID: <81B3654D-A99C-4216-A207-0522C9E8AA68@netng.pl> (raw)
In-Reply-To: <d3f6b579-0fe0-0f97-1438-79c10e88bb96@hesbynett.no>



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

  reply	other threads:[~2019-02-23 18:38 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
2019-02-23 18:38   ` Łukasz Kostka [this message]
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=81B3654D-A99C-4216-A207-0522C9E8AA68@netng.pl \
    --to=lukasz.kostka@netng.pl \
    --cc=david.brown@hesbynett.no \
    --cc=gcc@gcc.gnu.org \
    /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).