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

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

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


From: Martin Krüger
Subject: Antworten: [avr-gcc-list] Array of pointers to functions
Date: Sat, 17 Jul 2004 09:59:15 GMT

 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]