[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] New pgm_read_ptr() macro?

From: Jan Waclawek
Subject: Re: [avr-libc-dev] New pgm_read_ptr() macro?
Date: Tue, 1 Jun 2010 15:25:20 +0200

I was about to suggest the same, but you've beaten me ;-)

The story (marginally related): I have developed a couple of similar macros 
(taking the "object" rather than pointer as a parameter) while playing with the 
_far variety of pgm_read_xxx. My intention was to merge ELPMs with taking of 
the "far pointer" via Carlos Lamas' GET_FAR_ADDRESS macro, potentially reducing 
the code a bit and sparing one register.

To my astonishment, in all but trivial programs such convoluted piece of 
assembler in fact INCREASED both code size and register usage! In spite of all 
my efforts, the register allocator saw my chunk of program as an obstacle and 
allocated more registers than originally for the surrounding operations. So all 
what my asm spared in code size went to function prologues/epilogues...

There are limitations to the method, though, e.g. when using it on array 
members, so it has to be used with appropriate caution (and documented 

Jan Waclawek

----- Original Message ---------------

Subject: Re: [avr-libc-dev] New pgm_read_ptr() macro?
   From: David Brown <address@hidden>

>How about a more general solution based on typeof and sizeof?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]