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

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

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


From: Royce & Sharal Pereira
Subject: [avr-gcc-list] Re: Array of pointers to functions
Date: Mon, 19 Jul 2004 10:20:12 +0530

Hi Russell,

> 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' ?
>     }
> //---------------------
>
> Many Thanks,
>
> --Royce.

I'd try:

   typedef (*call_fun)(void);

   call_fun cfa[]={fun1,fun2,fun3};

   void main(void)
   {
     cfa[f_cnt]();
   }
//----------------------------
I tried your suggestion,,,but the array seems to be initialised in RAM. which 
also means no LPM
again to fetch the function address...

I'm getting the feeling no-one has tried this yet! But I use it commonly with 
SDCC (mcs51) with
great results!

Thanks!

--Royce.





reply via email to

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