Help with jump between functions

I have 3 isr's ( interrupt service routines)

isr1()
{


}

isr2()
{


}

isr3()
{



}

all the 3 isrs have a particular statement that i want to be executed only when the jump is from isr to another. The statement should be skipped if the jump is back to the same isr. How do i go about this?

Thank you
closed account (zb0S216C)
What language are you using? Can you be more clear on what you're asking, please.

Wazzak
Does this look good?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cstdio>
#include <cstdlib>
#include <ctime>

int from_isr;

void isr1();
void isr2();
void isr3();

const int max_jumps = 20;
int total_jumps = 0;

#define MSG(id) if (from_isr != id) printf("lalalalalalala");

#define JUMP(from_id,to_id,p) if (++total_jumps > max_jumps) return; from_isr = from_id; \
    if (rand()%p) { printf("\nisr" #from_id " -> isr" #to_id " "); isr##to_id(); }

void isr1() { MSG(1) JUMP(1,1,2) JUMP(1,2,2) JUMP(1,3,100) }
void isr2() { MSG(2) JUMP(2,2,2) JUMP(2,1,2) JUMP(2,3,100) }
void isr3() { MSG(3) JUMP(3,3,2) JUMP(3,1,2) JUMP(3,2,100) }

int main()
{
    srand(time(0));

    printf("main -> isr1 ");

    isr1();

    printf("\n\n(hit enter to quit...)");
    getchar();

    return 0;
}
Topic archived. No new replies allowed.