We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
The simplest code is to use a switch statement.
enum{ State0, State1, State2 }; void irq (void) interrupt 0x14 using irq_level_2 { static unsigned char State; switch( State ) { State0: //do stuff State = State1; break; State1: //do stuff State = State2; break; State2: //do stuff State = State0; break; } }