avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Pointers below address 32


From: Dmitry K.
Subject: Re: [avr-gcc-list] Pointers below address 32
Date: Tue, 10 May 2005 10:56:44 +1100
User-agent: KMail/1.5

On Tuesday 10 May 2005 09:10, Björn Haase wrote:
> Jörg Wunsch wrote:
> >I'm not sure.  On the AVR, memory address 0 is an alias for r0.  Thus,
> >by dereferencing a NULL pointer, you're touching whatever r0 (rather
> >r0/r1) points to.  As this can touch anywhere (including memory-mapped
> >IO devices), the behaviour is completely undefined, and you should
> >probably avoid that kind of program anyway.
>
> I never tried it, but is it actually really possible to access registers by
> using pointer expressions? If that's possible, one could possibly shorten
> the function prologues and epilogues considerably when optimizing for size.
> E.g. with a sequence like
>
>       ldi r30,26
>       ldi r31,0
>       ldi r27,12 ; Save 12 registers starting from r(26-1) == r25
>       loop:
>       ld __tmp_reg__,-z
>       push __tmp_reg__
>       dec r27
>       brne loop
>

Yes, this is common method for initial cleaning variables (in registers)
for pure asm programs.

Prologue/epilogue?  In max case (r2-r17, r28,r29):
  With pushes:   18 words,  36 clocks
  With loop:      9 words, 119 clocks

Dmitry.





reply via email to

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