goto to a pointer

Hello NG,
I've got the following problem: I want to store the current position in a interrupt routine and leave it. By entering the routine after the next interrupt, I want to jump to this stored position. My first idea was the following:

void irq (void) interrupt 0x14 using irq_level_2
{
static int flag = 0;
static void (*cont_here) ();

if (flag!=0) goto *cont_here;
...
if (something)
{
flag = 1;
cont_here = &here1;
goto end_irq;
}
here1:
...
if (something_else)
{
flag = 1;
cont_here = &here2;
goto end_irq;
}
here2:
...
end_irq:
}

But it doesn't work, 'cause labels and variables aren't the same and goto *bla doesn't work.
Is there a solution besides the using of setjmp and longjump (which got too much, in this case, senseless overhead)?

Thanks for any ideas - Peter

Parents
  • You could do it just the way they do it with setjmp/longjmp, that is, extract address of the return point from the system stack and than use it as a pointer to a function. You don't even have to resort to assembler. But you have to take into account the memory model in use (whether function calls are 'near' or 'far').
    Good luck!
    Mike.

Reply
  • You could do it just the way they do it with setjmp/longjmp, that is, extract address of the return point from the system stack and than use it as a pointer to a function. You don't even have to resort to assembler. But you have to take into account the memory model in use (whether function calls are 'near' or 'far').
    Good luck!
    Mike.

Children
More questions in this forum