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

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

AW: Antworten: [avr-gcc-list] Array of pointers to functions


From: Oliver Schulz
Subject: AW: Antworten: [avr-gcc-list] Array of pointers to functions
Date: Sat, 17 Jul 2004 12:31:23 +0200

Hi,

I suggest to use __LPM_word instead of __LPM_word_classic__, depending on
the used avr, the compiler automatically chooses the right marco...

Cheers,
Oliver.

> -----Ursprüngliche Nachricht-----
> Von: address@hidden
> [mailto:address@hidden Auftrag von Martin Krüger
> Gesendet: Samstag, 17. Juli 2004 11:59
> An: Royce & Sharal Pereira
> Cc: AVR-GCC
> Betreff: Antworten: [avr-gcc-list] Array of pointers to functions
>
>
>  Ursprüngliche Nachricht -------
> Von:  Royce & Sharal Pereira  <address@hidden>
> Datum: Sat, 17 Jul 2004 13:01:39 +0530
> Betreff: [avr-gcc-list] Array of pointers to functions
>
> Hi, all,
>
> I'm trying to call a function from an array, like this..
>
> char f_cnt;
>
> void fun1(void)
>     {
>         //some code
>     }
> //---------------------
> void fun2(void)
>     {
>         //some code
>     }
> //---------------------
> void fun3(void)
>     {
>         //some code
>     }
> //---------------------
>
> void (*call_fun[])() PROGMEM = { fun1, fun2, fun3};  //This
> puts the addresses in code memory(seems
> so from the .lst file).
> //----------------------
> void main(void)
>     {
>         (*call_fun[f_cnt])();  //But here I get a 'ld'
> instruction. How to cause an LPM instruction
> to get the function address before the 'icall' ?
>     }
> //---------------------
>
> Hello Royce
> Try this:
>
>
> void (*func)();
> func=(__LPM_word_classic__((PGM_P)call_fun[0]));
> (func());
>
> I looked in the produces .s file,seems to be ok.
>
> Martin
>
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
> Fußball EM 2004: Alle Spiele, alle Tore bei Lycos Sport unter
http://em2004.lycos.de!




reply via email to

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