[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Pointer to a function in a structure in flash?
From: |
E . Weddington |
Subject: |
Re: [avr-gcc-list] Pointer to a function in a structure in flash? |
Date: |
Tue, 28 Oct 2003 16:44:42 GMT |
>
>
> On Tue, 28 Oct 2003, Bob Paddock wrote:
>
> > On Mon, 27 Oct 2003 22:20:30 GMT, E.Weddington
<address@hidden> wrote:
> >
> > >> #if defined( __GCC_VERSION__ )
> > >> retval =
> > >> (*((functype_t)(pgm_read_word(&cmd_func_table
[i].function))))(
> > >> (char const *)token,
> > >> (char const *)tokptr);
> > >> #endif
>
> [snip]
>
> > I tried that and the system goes off to never-never-
land, what I have
> > above works, below does not (I did change [0] to [i] as
required).
> >
> > > #if defined( __GCC_VERSION__ )
> > > retval = cmd_func_table[0].function((CONST char *)
token,
> > > (CONST char *) tokptr);
> > > #endif
>
> I don't think this second version is ever reading the
function pointer
> from program space which is why is goes to never-never-
land. It
> should probably look something like this:
>
> #if defined( __GCC_VERSION__ )
> functype_t func = (functype_t)pgm_read_word
(&cmd_func_table[i].function);
> retval = func ((CONST char *) token, (CONST char *)
tokptr);
> #endif
>
> The code that Eric posted yesterday had the same problem.
If you look
> at the assembly listing, there was no LPM insn to pull
the function
> from program space.
>
> Ted Roth
>
D'oh! Thanks for catching that Ted. Mea culpa.
Eric
- Re: [avr-gcc-list] Pointer to a function in a structure in flash?, (continued)