I don't want to go back to the line from where Interrupt is generated

104 Views Asked by At

Usually when interrupt occurs, program returns to the line from where interrupt is generated.

I want to run the program from new line after ISR routine is completed, i.e. I don't want it to go back from where interrupt is generated.

would I have to change IP stored in SP Or what else?

thanks

2

There are 2 best solutions below

0
On

PC(Program Counter)commonly called the instruction pointer (IP) in Intel x86 will store the next instruction address. you need to change PC to the Newline at End of Interrupt routinue.

you can Also increment Pc VAlue which is store in stack at the end of Interrupt routine, then would be stored in the PC.

0
On

Your ISR has no idea of the point of execution of what it has interrupted and no clue as to what is stored on the stack of what it has interrupted. Just 'jumping' to another 'line', without a stack-cleanup operation, (which is not possible 'cos you don't know what's on it), will generate UB, (probably UB erring on the AV/segFault side).

The only way I know of to achieve something like what seem to want is to swap to a different stack - signal a semaphore/event upon which a thread is waiting and request an OS scheduler run on ISR exit. The newly-ready thread may well then run immediately after the ISR completes, (depending on loading/priorities etc), maybe even preempting the thread that was interrupted and so 'run the program from new line', sort-of.. :)