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

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

[avr-gcc-list] Re: Solution to function pointers in program memory-FYI


From: Guy Robinson
Subject: [avr-gcc-list] Re: Solution to function pointers in program memory-FYI
Date: Mon, 7 May 2001 23:26:52 +1200

 Hi Harald,

 This is what Larry had suggested first. Although this worked with a local
 variable passing the address, when I tried to use a global pointer it was
 picking up the wrong registers. Hence the A1 and B1 in my macro (R24,R25).
 My program has changed already with more code in the RunFunc() and it still
 compiles correctly, so my macro seems reasonably robust when the addr is
 global.

 I've just started to read your .pdf on assembly for more assem clues.

 Guy

 ----- Original Message -----
 From: "Harald Kipp" <address@hidden>
 To: <address@hidden>
 Sent: Monday, May 07, 2001 11:17 PM
 Subject: Re: [avr-gcc-list] Solution to function pointers in program
 memory-FYI


 > How about
>
> #define pgm_rw(addr) ({     \
>     u16 __word;             \
>     __asm__ (               \
>         "lpm\n\t"           \
>         "mov %A0, r0\n\t" \
>         "adiw r30, 1\n\t"  \
>         "lpm\n\t"           \
>         "mov %B0, r0\n\t" \
>         : "=&r" (__word)     \
>         : "z" ((u16)(addr)) \
>         : "r0" );           \
>     __word;                 \
> })
>
> The clobbered r0 need not to be specified. However,
> I'd leave it, because otherwise the macro depends
> on r0 defined as __tmp_reg__. As far as I know,
> putting r0 in the clobber list won't hurt.
>
> Harald Kipp
>
> egnite Software GmbH     TEL +49 (0)2323-925375
> Westring 303             FAX +49 (0)2323-925374
> 44629 Herne
> Germany
>
> Embedded Ethernet - http://www.egnite.de/
>
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
>





reply via email to

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